Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Resolved hello-world = (404) HTTP/1.1 404 Not Found

Discussion in 'Cloud Code' started by pKallv, Mar 30, 2024.

  1. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,191
    Hi,
    I am following the Get Started with UGS Cloud Code tutorial. I get the "404 Not Found" error and have been trying to solve it but with no success. I am authorised before I execute the Cloud Code function.

    Anyone that can help would be appreciated.

    Code (CSharp):
    1. NotFound
    2. (404) HTTP/1.1 404 Not Found
    3. Error
    4. Script could not be found
    5.  
    6. UnityEngine.Debug:LogError (object)
    7. Unity.Services.CloudCode.CloudCodeInternal:BuildException (bool,long,int,string,Unity.Services.CloudCode.Internal.Http.HttpException) (at ./Library/PackageCache/com.unity.services.cloudcode@2.5.1/Runtime/CloudCode.cs:181)
    8. Unity.Services.CloudCode.CloudCodeInternal/<GetRunScriptResponse>d__15:MoveNext () (at ./Library/PackageCache/com.unity.services.cloudcode@2.5.1/Runtime/CloudCode.cs:111)
    9. System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.CloudCode.Internal.Response`1<Unity.Services.CloudCode.Internal.Models.RunScriptResponse>>:SetException (System.Exception)
    10. Unity.Services.CloudCode.CloudCodeInternal/<GetResponseAsync>d__20:MoveNext () (at ./Library/PackageCache/com.unity.services.cloudcode@2.5.1/Runtime/CloudCode.cs:234)
    11. System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.CloudCode.Internal.Response`1<Unity.Services.CloudCode.Internal.Models.RunScriptResponse>>:SetException (System.Exception)
    12. Unity.Services.CloudCode.Internal.Apis.CloudCode.CloudCodeApiClient/<RunScriptAsync>d__8:MoveNext () (at ./Library/PackageCache/com.unity.services.cloudcode@2.5.1/Runtime/com.unity.services.cloudcode.internal/Apis/CloudCodeApi.cs:167)
    13. System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.CloudCode.Internal.Http.HttpClientResponse>:SetResult (Unity.Services.CloudCode.Internal.Http.HttpClientResponse)
    14. Unity.Services.CloudCode.Internal.Http.HttpClient/<MakeRequestAsync>d__2:MoveNext () (at ./Library/PackageCache/com.unity.services.cloudcode@2.5.1/Runtime/com.unity.services.cloudcode.internal/Http/HttpClient.cs:44)
    15. System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.CloudCode.Internal.Http.HttpClientResponse>:SetResult (Unity.Services.CloudCode.Internal.Http.HttpClientResponse)
    16. Unity.Services.CloudCode.Internal.Http.HttpClient/<CreateWebRequestAsync>d__4:MoveNext () (at ./Library/PackageCache/com.unity.services.cloudcode@2.5.1/Runtime/com.unity.services.cloudcode.internal/Http/HttpClient.cs:69)
    17. System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.CloudCode.Internal.Http.HttpClientResponse>:SetResult (Unity.Services.CloudCode.Internal.Http.HttpClientResponse)
    18. Unity.Services.CloudCode.Internal.Http.HttpClient/<CreateHttpClientResponse>d__6:MoveNext () (at ./Library/PackageCache/com.unity.services.cloudcode@2.5.1/Runtime/com.unity.services.cloudcode.internal/Http/HttpClient.cs:105)
    19. System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.CloudCode.Internal.Http.HttpClientResponse>:SetResult (Unity.Services.CloudCode.Internal.Http.HttpClientResponse)
    20. Unity.Services.CloudCode.Internal.Http.HttpClient/<>c__DisplayClass6_0/<<CreateHttpClientResponse>b__0>d:MoveNext () (at ./Library/PackageCache/com.unity.services.cloudcode@2.5.1/Runtime/com.unity.services.cloudcode.internal/Http/HttpClient.cs:102)
    21. System.Threading.Tasks.TaskCompletionSource`1<Unity.Services.CloudCode.Internal.Http.HttpClientResponse>:SetResult (Unity.Services.CloudCode.Internal.Http.HttpClientResponse)
    22. Unity.Services.CloudCode.Internal.Http.UnityWebRequestHelpers/<>c__DisplayClass0_0:<GetAwaiter>b__0 (UnityEngine.AsyncOperation) (at ./Library/PackageCache/com.unity.services.cloudcode@2.5.1/Runtime/com.unity.services.cloudcode.internal/Http/UnityWebRequestHelpers.cs:34)
    23. UnityEngine.AsyncOperation:InvokeCompletionEvent () (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/AsyncOperation.cs:21)
    24.  

    Code (CSharp):
    1. HttpException`1: (404) HTTP/1.1 404 Not Found
    2. Unity.Services.CloudCode.Internal.Http.ResponseHandler.HandleAsyncResponse (Unity.Services.CloudCode.Internal.Http.HttpClientResponse response, System.Collections.Generic.Dictionary`2[TKey,TValue] statusCodeToTypeMap) (at ./Library/PackageCache/com.unity.services.cloudcode@2.5.1/Runtime/com.unity.services.cloudcode.internal/Http/ResponseHandler.cs:122)
    3. Unity.Services.CloudCode.Internal.Http.ResponseHandler.HandleAsyncResponse[T] (Unity.Services.CloudCode.Internal.Http.HttpClientResponse response, System.Collections.Generic.Dictionary`2[TKey,TValue] statusCodeToTypeMap) (at ./Library/PackageCache/com.unity.services.cloudcode@2.5.1/Runtime/com.unity.services.cloudcode.internal/Http/ResponseHandler.cs:226)
    4. Unity.Services.CloudCode.Internal.Apis.CloudCode.CloudCodeApiClient.RunScriptAsync (Unity.Services.CloudCode.Internal.CloudCode.RunScriptRequest request, Unity.Services.CloudCode.Internal.Configuration operationConfiguration) (at ./Library/PackageCache/com.unity.services.cloudcode@2.5.1/Runtime/com.unity.services.cloudcode.internal/Apis/CloudCodeApi.cs:166)
    5. Unity.Services.CloudCode.CloudCodeInternal.GetResponseAsync (System.String function, System.Collections.Generic.Dictionary`2[TKey,TValue] args) (at ./Library/PackageCache/com.unity.services.cloudcode@2.5.1/Runtime/CloudCode.cs:234)
    6. Unity.Services.CloudCode.CloudCodeInternal.GetRunScriptResponse (System.String function, System.Collections.Generic.Dictionary`2[TKey,TValue] args) (at ./Library/PackageCache/com.unity.services.cloudcode@2.5.1/Runtime/CloudCode.cs:107)
    7. Rethrow as CloudCodeException: NotFound
    8. (404) HTTP/1.1 404 Not Found
    9. Error
    10. Script could not be found
    11. Unity.Services.CloudCode.CloudCodeInternal.GetRunScriptResponse (System.String function, System.Collections.Generic.Dictionary`2[TKey,TValue] args) (at ./Library/PackageCache/com.unity.services.cloudcode@2.5.1/Runtime/CloudCode.cs:111)
    12. Unity.Services.CloudCode.CloudCodeInternal.CallEndpointAsync[TResult] (System.String function, System.Collections.Generic.Dictionary`2[TKey,TValue] args) (at ./Library/PackageCache/com.unity.services.cloudcode@2.5.1/Runtime/CloudCode.cs:45)
    13. Manager.BTN_Run () (at Assets/Manager.cs:93)
    14. System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) (at <58ad0307846e4e2aa7b395ea5a7758f5>:0)
    15. UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/UnitySynchronizationContext.cs:153)
    16. UnityEngine.UnitySynchronizationContext.Exec () (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/UnitySynchronizationContext.cs:83)
    17. UnityEngine.UnitySynchronizationContext.ExecuteTasks () (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/UnitySynchronizationContext.cs:107)
    18.  
    Screenshot 2024-03-30 at 10.43.35.png

    Screenshot 2024-03-30 at 10.43.52.png


    CODE:

    Code (CSharp):
    1. using System;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using System.Threading.Tasks;
    5. using Unity.Services.Authentication;
    6. using Unity.Services.Core;
    7. using UnityEngine;
    8. using UnityEngine.UI;
    9. using TMPro;
    10. using Unity.Services.CloudCode;
    11.  
    12.  
    13.  
    14. public class Manager : MonoBehaviour
    15. {
    16.     public Image img_Status;
    17.     public TMP_Text txt_Log;
    18.  
    19.  
    20.     /*
    21.      * CloudCodeResponse represents the response from the script, used for deserialization.
    22.      * In this example, the script returns a JSON in the format
    23.      * {"welcomeMessage": "Hello, arguments['name']. Welcome to Cloud Code!"}
    24.      */
    25.     class CloudCodeResponse
    26.     {
    27.         public string welcomeMessage;
    28.     }
    29.  
    30.     /*
    31.      * Initialize all Unity Services and Sign In an anonymous player.
    32.      * You can perform this operation in a more centralized spot in your project
    33.      */
    34.     private async void Awake()
    35.     {
    36.         img_Status.color = Color.red;
    37.         txt_Log.text += ">> START <<\n";
    38.      
    39.         {
    40.             try
    41.             {
    42.                 await UnityServices.InitializeAsync();
    43.             }
    44.             catch (Exception e)
    45.             {
    46.                 txt_Log.text += "Exception: " + e + "\n";
    47.                 img_Status.color = Color.red;
    48.             }
    49.         }
    50.      
    51.      
    52.         await SignInAnonymouslyAsync();
    53.     }
    54.  
    55.  
    56.     async Task SignInAnonymouslyAsync()
    57.     {
    58.         try
    59.         {
    60.             await AuthenticationService.Instance.SignInAnonymouslyAsync();
    61.             Debug.Log("Sign in anonymously succeeded!\n");
    62.      
    63.             // Shows how to get the playerID
    64.             txt_Log.text += "LOGIN SUCCESSFUL\n";
    65.             txt_Log.text += "PlayerID: " + AuthenticationService.Instance.PlayerId + "\n";
    66.             txt_Log.text += "----------------------------------\n";
    67.             img_Status.color = Color.green;
    68.  
    69.         }
    70.         catch (AuthenticationException ex)
    71.         {
    72.             // Compare error code to AuthenticationErrorCodes
    73.             // Notify the player with the proper error message
    74.             txt_Log.text += "AuthenticationException: " + ex + "\n";
    75.             img_Status.color = Color.red;
    76.         }
    77.         catch (RequestFailedException ex)
    78.         {
    79.             // Compare error code to CommonErrorCodes
    80.             // Notify the player with the proper error message
    81.             txt_Log.text += "RequestFailedException: " + ex + "\n";
    82.             img_Status.color = Color.red;
    83.         }
    84.     }
    85.  
    86.     /*
    87.      * Populate a Dictionary<string,object> with the arguments and invoke the script.
    88.      * Deserialize the response into a CloudCodeResponse object
    89.      */
    90.     public async void BTN_Run()
    91.     {
    92.         var arguments = new Dictionary<string, object> { { "name", "UNITY" } };
    93.         var response = await CloudCodeService.Instance.CallEndpointAsync<CloudCodeResponse>("hello-world", arguments);
    94.     }
    95. }
    96.  
     
  2. MariusUrbelis

    MariusUrbelis

    Unity Technologies

    Joined:
    Mar 15, 2015
    Posts:
    39
    Hi. I'm sure you've already linked your Unity project with this specific cloud project "UGS_Test_Platform"?
     
    pKallv likes this.
  3. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,191
    Oh my ... I mixed the names. Thank you vey much, now it works.
     
    MariusUrbelis likes this.