question

Dylan Hunt avatar image
Dylan Hunt asked

Inconsistent responses from server CloudScript

Spent a while wondering why the heck my code isn't working.

Docs show result.data.Data.preferences.Value as the example

However, the actual result returned result.Data.preferences.Value

This example was pulled from server.GetUserData but I'm sure this isn't the only one. Super confusing~

CloudScript
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

In the response to any API call, if there's anything in the response, that will always be in the section "data", like so:

{
  "code": 200,
  "status": "OK",
  "data": {
    // response properties go here
  }
}

In the case of some API calls, like all the Get...Data ones, there's a specific property in the response named "Data" (ex: https://api.playfab.com/documentation/server/method/GetUserData). So the response for those will always have something like this:

{
  "code": 200,
  "status": "OK",
  "data": {
    "Data": {
      // contents of the property Data go here
    }
  }
}

Now, in Cloud Script, what you're specifically getting back is the contents of the "data" section of the response - not the whole response body with the code and status (in the case of errors, you get the complete body of the response back in the apiError).

If you're seeing anywhere there's an inconsistency in this, can you please provide specifics?

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Dylan Hunt avatar image Dylan Hunt commented ·

Ahhhh so cloudscript skips that root parent level completely? That's with all calls eh? This helped, thanks!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.