question

dan avatar image
dan asked

Cloud Script GetPlayerCombinedInfo not returning any data

I wrote some Cloud Script to get user data...

handlers.getPlayerInfo = function (args) {
  	var playerID = null;
  	if (args && args.id) playerID = args.id;
    var request = {
        "PlayFabId": playerID,
  	"InfoRequestParameters": [{
          "GetUserAccountInfo": true,
          "GetUserInventory": false,
          "GetUserVirtualCurrency": false,
          "GetUserData": false,
          "GetUserReadOnlyData": false,
          "GetCharacterInventories": false,
          "GetCharacterList": false,
          "GetTitleData": false,
          "GetPlayerStatistics": false
	}]
    };    
    var playerInfoResult = server.GetPlayerCombinedInfo(request);
    return playerInfoResult;
};

But when executed from Postman, like so...

https://{
                {TitleId}}.playfabapi.com/Client/ExecuteCloudScript


{
  "FunctionName": "getPlayerInfo",
  "FunctionParameter": {
    "id": "59FCE1AD1A872162"
  },
  "RevisionSelection": "Live",
  "GeneratePlayStreamEvent": false
}

...the data seems to be missing from the result...

{
  "code": 200,
  "status": "OK",
  "data": {
    "FunctionName": "getPlayerInfo",
    "Revision": 13,
    "FunctionResult": {
      "PlayFabId": "59FCE1AD1A872162",
      "InfoResultPayload": {
        "UserDataVersion": 0,
        "UserReadOnlyDataVersion": 0
      }
    },
    "Logs": [],
    "ExecutionTimeSeconds": 0.16130509999999998,
    "ProcessorTimeSeconds": 0,
    "MemoryConsumedBytes": 30112,
    "APIRequestsIssued": 1,
    "HttpRequestsIssued": 0
  }
}

Any idea what might be wrong?

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

Yes, the problem is that InfoRequestParameters isn't an array - it's an object. If you remove the square brackets from the declaration of the value of that parameter, your function should work fine. So, here's the updated version:

handlers.getPlayerInfo = function(args) {
    var playerID = null;
    if (args && args.id) playerID = args.id;
    var request = {
        "PlayFabId": playerID,
        "InfoRequestParameters": {
            "GetUserAccountInfo": true,
            "GetUserInventory": false,
            "GetUserVirtualCurrency": false,
            "GetUserData": false,
            "GetUserReadOnlyData": false,
            "GetCharacterInventories": false,
            "GetCharacterList": false,
            "GetTitleData": false,
            "GetPlayerStatistics": false
        }
    };
    var playerInfoResult = server.GetPlayerCombinedInfo(request);
    return playerInfoResult;
};
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.

dan avatar image dan commented ·

D'oh! I could have sworn I already tried that. Thanks - works like a charm now! :D

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.