Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Question How to get rid of "Unprocessable Entity" in the non-production environment?

Discussion in 'Cloud Code' started by Kurutah, Apr 5, 2024.

  1. Kurutah

    Kurutah

    Joined:
    Jul 19, 2017
    Posts:
    11
    Going through tutorial but I get the error:

    "ScriptError (422) HTTP/1.1 422 Unprocessable Entity
    Unprocessable Entity
    Invocation Error
    ScriptRunner.Exceptions.CloudCodeRuntimeException: Error executing Cloud Code function. Exception type: KeyNotFoundException. Message: Key QUESTS not found in Remote Config settings" on this line:

    var result = gameApiClient.RemoteConfigSettings.AssignSettingsGetAsync(ctx, ctx.AccessToken, ctx.ProjectId,
    ctx.ProjectId, null, new List<string> { "QUESTS" });

    Then I checked many times, and actually, it works if I add the same "QUESTS" JSON to the "Production" environment. But how to make it work in other environments? Did I miss something?

    Thank you.
     
  2. samg-unity

    samg-unity

    Unity Technologies

    Joined:
    Mar 23, 2021
    Posts:
    47
    Hi @Kurutah

    I see theres actually an error in the sample there as the projectId is being passed twice, but the environmentId isn't, I believe the code snippet should be the following:

    Code (CSharp):
    1. var result = gameApiClient.RemoteConfigSettings.AssignSettingsGetAsync(ctx, ctx.AccessToken, ctx.ProjectId,
    2. ctx.EnvironmentId, null, new List<string> { "QUESTS" });
    When I get a chance I'll try it out but if that resolves your issue then I will get the documentation updated.
     
  3. Kurutah

    Kurutah

    Joined:
    Jul 19, 2017
    Posts:
    11
    Thank you, just found it out myself too. Yes, it works.

    Btw, another mistake for some newbies like me is the right format for JSON from the same page is:

    {
    "statements": [
    {
    "Sid": "deny-cloud-save-data-write-access",
    "Effect": "Deny",
    "Action": ["Write"],
    "Principal": "Player",
    "Resource": "urn:ugs:cloud-save:/v1/data/projects/*/players/*/items**"
    }
    ]
    }

    I spent much time trying to make work JSON from the page and it just doesn't
     
    GabKBelmonte and samg-unity like this.
  4. samg-unity

    samg-unity

    Unity Technologies

    Joined:
    Mar 23, 2021
    Posts:
    47
    Thanks for reporting those documentation issues @Kurutah The documentation should hopefully get updated soon.
     
    GabKBelmonte likes this.