question

Mathijs avatar image
Mathijs asked

GetInternalUserData unexpected empty Data/Keys result.

Hi! I've been fiddling around with PlayFab for a while. And now I've been diving into cloud scripting. And time for my first question ;)

The thing what I am trying to do is to get the User Internal Data.
I only want to get some of the keys.

I tried this in Postman so you can read the JSON server response.

So below the body GetUserInternalData method:

{
  "PlayFabId": "####",
  "Keys": [
    "rank",
    "shootingSkill"
  ]
}

Which results in:

{
  "code": 200,
  "status": "OK",
  "data": {
    "PlayFabId": "####",
    "DataVersion": 0,
    "Data": {}
  }
}

So it's working but the Data property is empty.

What could be the issue? There's internal player data with these keys and values:

  • rank: 1, public
  • shootingSkill: 0, private

Also logged in with the correct player ID.

Am I missing something?

apisPlayer Data
10 |1200

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

brendan avatar image
brendan answered

Can you please provide the Title ID and PlayFab ID? Those don't need to be removed - they're not really secret at all. Without your secret key or its credentials, others cannot alter that player account.

3 comments
10 |1200

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

Mathijs avatar image Mathijs commented ·

Hi @Brendan!

Of course here they are...

TitleID: 5170

PlayFabID: C4AC41910CFD7D31

Cheers!

0 Likes 0 ·
brendan avatar image brendan Mathijs commented ·

In getting back the data no problem when I test in Postman. Can you provide the details of the call you're making (though please do remove the SecretKey, as in the example below)?

POST /Server/GetUserInternalData HTTP/1.1
Host: 5170.playfabapi.com
Content-Type: application/json
X-SecretKey: {
                    {SecretKey}}
{
  "PlayFabId": "C4AC41910CFD7D31",
  "Keys": [
    "shootingSkill",
    "rank"
  ]
}

{
    "code": 200,
    "status": "OK",
    "data": {
        "PlayFabId": "C4AC41910CFD7D31",
        "DataVersion": 3,
        "Data": {
            "rank": {
                "Value": "1",
                "LastUpdated": "2016-09-16T14:01:23.961Z",
                "Permission": "Public"
            },
            "shootingSkill": {
                "Value": "0",
                "LastUpdated": "2016-09-16T14:01:23.961Z",
                "Permission": "Private"
            }
        }
    }
}
1 Like 1 ·
Mathijs avatar image Mathijs commented ·

Haha! This is what you get when you spend too much time looking at code when you're tired.

<shame on> I had the PlayFabId value mixed up with TitleId ;) </shame off>

Thank you @Brendan for your fast support!

0 Likes 0 ·
Mathijs avatar image
Mathijs answered

Hmmm, still have an issue with this cloud script:

handlers.getPlayerSkills = function (args) {
    server.GetUserInternalData({
        PlayFabId: currentPlayerId,
            Keys: [
                "rank", 
                "experience", 
                "shootingSkill", 
                "snipingSkill", 
                "throwingSkill", 
                "medSkill"
            ]
    });
    log.debug("Get player skills from internal data for player: " + currentPlayerId);
}

If I do a request in Postman, like this:

POST /Client/ExecuteCloudScript HTTP/1.1
Host: 5170.playfabapi.com
Content-Type: application/json
X-Authentication: C4AC41910CFD7D31-0-0-5170-8D3DF2999330100-6E10538BD0A0C967.98C02A1808E118E4
Cache-Control: no-cache
Postman-Token: 6313bdb7-aebf-6337-0e28-1c84a96ced16


{
	"FunctionName": "getPlayerSkills"
}

I get this in return:

{
  "code": 200,
  "status": "OK",
  "data": {
    "FunctionName": "getPlayerSkills",
    "Revision": 8,
    "Logs": [
      {
        "Level": "Debug",
        "Message": "Get player skills from internal data for player: C4AC41910CFD7D31"
      }
    ],
    "ExecutionTimeSeconds": 0.120684,
    "ProcessorTimeSeconds": 0,
    "MemoryConsumedBytes": 32592,
    "APIRequestsIssued": 1,
    "HttpRequestsIssued": 0
  }
}

Same in Unity:

{
"FunctionName":"getPlayerSkills",
"Revision":8,"FunctionResult":null,"Logs":[	{		"Level":		"Debug",		"Message":"Get player skills from internal data 			for player: C4AC41910CFD7D31",		"Data":null

		}
	],"ExecutionTimeSeconds":0.1052019,"MemoryConsumedBytes":32592,"APIRequestsIssued":1,"HttpRequestsIssued":0,"Error":null,"Request":	{
		"FunctionName":"getPlayerSkills",
		"FunctionParameter":null,		"RevisionSelection":null,		"SpecificRevision":null,		"GeneratePlayStreamEvent":null
	},"CustomData":null

}

I guess my method in the cloud script contains an error... but still I followed just the documentation.

Also the right PlayFabId is returned.

What do I not grasp?

Cheers,

Mathijs

10 |1200

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

brendan avatar image
brendan answered

Sorry, but where are you seeing an error? You're querying for the data, then logging what player you made that call for. Everything seems to work as expected. My question would be, what did you want to do with that data? Right now, you're not capturing the return value from that call, so you can't even return it to the client. Also, though, if you're going to let the player query the data anyway, why not just use User Read Only Data?

2 comments
10 |1200

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

Mathijs avatar image Mathijs commented ·

Yo! Brendan!

I've had to leave this thing for some other work... and now I am back to this... I made it work in just 5 minutes! Must have been blind somewhere.

Just wanted you to know! Thank you for your patience!

You can close this post or better, delete it if you want ;)

0 Likes 0 ·
brendan avatar image brendan Mathijs commented ·

Thanks for the follow-up - glad to hear you got it working. No need to delete any posts - they could provide useful info to others later on. :)

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.