I am working on a game and using CC to access my cloud database. All have been working well but after spending time on other part of the game for about a month+ something have changed, and I have not touched the cc part of the code:
ScriptError
(422) HTTP/1.1 422 Unprocessable Entity
Unprocessable Entity
Invocation Error
ScriptRunner.Exceptions.ModuleNotFoundException: Module with the name GetAccessToken was not found. Ensure that it is published to Cloud Code for the correct environment
UnityEngine.Debug:LogError (object)
Unity.Services.CloudCode.CloudCodeInternal:BuildException (bool,long,int,string,Unity.Services.CloudCode.Internal.Http.HttpException) (at ./Library/PackageCache/com.unity.services.cloudcode@2.6.1/Runtime/CloudCode.cs:181)
Unity.Services.CloudCode.CloudCodeInternal/<GetRunModuleScriptResponse>d__16:MoveNext () (at ./Library/PackageCache/com.unity.services.cloudcode@2.6.1/Runtime/CloudCode.cs:149)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.CloudCode.Internal.Response`1<Unity.Services.CloudCode.Internal.Models.RunModuleResponse>>:SetException (System.Exception)
Unity.Services.CloudCode.CloudCodeInternal/<GetModuleResponseAsync>d__21:MoveNext () (at ./Library/PackageCache/com.unity.services.cloudcode@2.6.1/Runtime/CloudCode.cs:243)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.CloudCode.Internal.Response`1<Unity.Services.CloudCode.Internal.Models.RunModuleResponse>>:SetException (System.Exception)
Unity.Services.CloudCode.Internal.Apis.CloudCode.CloudCodeApiClient/<RunModuleAsync>d__7:MoveNext () (at ./Library/PackageCache/com.unity.services.cloudcode@2.6.1/Runtime/com.unity.services.cloudcode.internal/Apis/CloudCodeApi.cs:138)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.CloudCode.Internal.Http.HttpClientResponse>:SetResult (Unity.Services.CloudCode.Internal.Http.HttpClientResponse)
Unity.Services.CloudCode.Internal.Http.HttpClient/<MakeRequestAsync>d__2:MoveNext () (at ./Library/PackageCache/com.unity.services.cloudcode@2.6.1/Runtime/com.unity.services.cloudcode.internal/Http/HttpClient.cs:44)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.CloudCode.Internal.Http.HttpClientResponse>:SetResult (Unity.Services.CloudCode.Internal.Http.HttpClientResponse)
Unity.Services.CloudCode.Internal.Http.HttpClient/<CreateWebRequestAsync>d__4:MoveNext () (at ./Library/PackageCache/com.unity.services.cloudcode@2.6.1/Runtime/com.unity.services.cloudcode.internal/Http/HttpClient.cs:69)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.CloudCode.Internal.Http.HttpClientResponse>:SetResult (Unity.Services.CloudCode.Internal.Http.HttpClientResponse)
Unity.Services.CloudCode.Internal.Http.HttpClient/<CreateHttpClientResponse>d__6:MoveNext () (at ./Library/PackageCache/com.unity.services.cloudcode@2.6.1/Runtime/com.unity.services.cloudcode.internal/Http/HttpClient.cs:105)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.CloudCode.Internal.Http.HttpClientResponse>:SetResult (Unity.Services.CloudCode.Internal.Http.HttpClientResponse)
Unity.Services.CloudCode.Internal.Http.HttpClient/<>c__DisplayClass6_0/<<CreateHttpClientResponse>b__0>d:MoveNext () (at ./Library/PackageCache/com.unity.services.cloudcode@2.6.1/Runtime/com.unity.services.cloudcode.internal/Http/HttpClient.cs:102)
System.Threading.Tasks.TaskCompletionSource`1<Unity.Services.CloudCode.Internal.Http.HttpClientResponse>:SetResult (Unity.Services.CloudCode.Internal.Http.HttpClientResponse)
Unity.Services.CloudCode.Internal.Http.UnityWebRequestHelpers/<>c__DisplayClass0_0:<GetAwaiter>b__0 (UnityEngine.AsyncOperation) (at ./Library/PackageCache/com.unity.services.cloudcode@2.6.1/Runtime/com.unity.services.cloudcode.internal/Http/UnityWebRequestHelpers.cs:34)
UnityEngine.AsyncOperation:InvokeCompletionEvent () (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/AsyncOperation.cs:21)
The module does exist in CC.
Code to access looks like this:
public async Task<string> GetAccessToken()
{
C2FUtility.Log("========== GetAccessToken ==========");
try
{
// Call the function within the module and provide the parameters we defined in there
var _module = new GetAccessTokenBindings(CloudCodeService.Instance);
var _jsonResult = await _module.GetAccessToken("dummy");
C2FUtility.Log("GetAccessToken jsonResult: " + _jsonResult);
return _jsonResult;
}
catch (CloudCodeException ex)
{
C2FUtility.Log("GetAccessTokenException: " + ex);
return ex.ToString();
}
}
Binding:
// This file was generated by Cloud Code Bindings Generator. Modifications will be lost upon regeneration.
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Unity.Services.CloudCode.GeneratedBindings
{
public class GetAccessTokenBindings
{
readonly ICloudCodeService k_Service;
public GetAccessTokenBindings(ICloudCodeService service)
{
k_Service = service;
}
public async Task<string> GetAccessToken(string _dummy)
{
return await k_Service.CallModuleEndpointAsync<string>(
"GetAccessToken",
"GetAccessToken",
new Dictionary<string, object>()
{
{"_dummy", _dummy}
});
}
}
}
