question

casper7609@naver.com avatar image
casper7609@naver.com asked

UpdateUserInventoryItemCustomData api does not work both on web and cloud

info from cloud script:

info: "PlayFabId 1D3498A7B1713815"
info: "CharacterId 2FD6E9E446BF2923"
info: "ItemInstanceId B2A61308AD888AF0"
info: "Data {\"MinimumDamage\":\"2\",\"MaximumDamage\":\"4\",\"MaxDurability\":\"10\",\"HandType\":\"TwoHand\"}"

and my cloud script is like

log.info("PlayFabId " + args.PlayFabId);
    log.info("CharacterId " + args.CharacterId);
    log.info("ItemInstanceId " + args.ItemInstanceId);
    log.info("Data " + JSON.stringify(args.Data));
    log.info("KeysToRemove " + args.KeysToRemove);
    server.LogEvent(args);
    return server.UpdateUserInventoryItemCustomData({
        PlayFabId: currentPlayerId,
        CharacterId: args.CharacterId,
        ItemInstanceId: args.ItemInstanceId,
        Data: args.Data,
    });

 

Also, tried the same thing via web api thing but it also didn't work. it gave me

{
"code": 503,
"status": "Service Unavailable",
"error": "Connection error",
"errorCode": 2,
"errorMessage": "",
"CallBackTimeMS": 540
}

 

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

The fix for this is now live in the service, so you shouldn't encounter it anymore (even if you don't specify the RevisionSelection).

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

We actually have a fix in test right now for this. The new ExecuteCloudScript (which replaces the GetCloudScriptUrl/RunCloudScript pair) has an issue in the SDK, in that the RevisionSelection is being sent as null when it's not present in your call. We're updating the SDK to not send null values for nullable types that don't have values, but we're also updating the backend to use the default if a null is sent (it already uses the default if RevisionSelection isn't in the call at all). For now, if you add "RevisionSelection": "Live" to your call, it will work fine. The backend fix will be rolled live either today or tomorrow.

10 |1200

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

casper7609@naver.com avatar image
casper7609@naver.com answered

First of all, I've been using GetCloudScriptUrl/RunCloudScript pair not the ExecuteCloudScript.

And also tried  "RevisionSelection": "Live" thing like

//server side

handlers.CloudUpdateUserInventoryItemCustomData = function (args)
{
    log.info("PlayFabId " + args.PlayFabId);
    log.info("CharacterId " + args.CharacterId);
    log.info("ItemInstanceId " + args.ItemInstanceId);
    log.info("Data " + JSON.stringify(args.Data));
    log.info("KeysToRemove " + args.KeysToRemove);
    log.info("RevisionSelection " + args.RevisionSelection);
    server.LogEvent(args);
    return server.UpdateUserInventoryItemCustomData({
        PlayFabId: currentPlayerId,
        CharacterId: args.CharacterId,
        ItemInstanceId: args.ItemInstanceId,
        RevisionSelection: args.RevisionSelection,
        Data: args.Data,
    });
};

 

//client side

PlayFabClientAPI.GetCloudScriptUrl(new GetCloudScriptUrlRequest()
        {
            Testing = false
        }, (success) => {
            Debug.Log("URL is set");

            RunCloudScriptRequest request = new RunCloudScriptRequest()
            {
                ActionId = "CloudUpdateUserInventoryItemCustomData",
                Params = new Dictionary<string, object>()
                {
                    {"RevisionSelection", "Live" },
                    { "PlayFabId" , LoginManager.PlayFabId},
                    { "CharacterId" , characterResult.CharacterId},
                    { "ItemInstanceId" , itemId},
                    { "Data", customDataDic}
                    //{ "Data", PlayFab.SimpleJson.SerializeObject(customDataDic)}
                }
            };
            PlayFabClientAPI.RunCloudScript(request, (result) =>
            {
                Debug.Log("Got log entries:");
                Debug.Log(result.ActionLog);
                Debug.Log("and return value: " + result.Results.ToString());
            }, (error) => {
                Debug.Log("Error calling helloWorld in Cloud Script:");
                Debug.Log(error.ErrorMessage);
            });
            foreach (var c in customDataDic)
            {
                Debug.Log(c.Key + " " + c.Value);
            }

        },
        (error) => {
            Debug.Log("Failed to retrieve Cloud Script URL");
        });

but it didn't work. I will give a try for ExecuteCloudScript and wait till it's been fixed

 

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

The RevisionSelection parameter is an input to the ExecuteCloudScript function, as opposed to an argument you would pass into your Cloud Script function. I would recommend moving to ExecuteCloudScript in your code in general, as it's simpler to use - the old API calls will continue to work for older titles, but developers should move to the new one, at this point.

If you're getting a 503 when calling RunCloudScript, could you get a wireshark or netmon capture of the traffic for the call? What all is in your customDataDic? What happens if you stringify the parameters for your call and pass them in as ParamsEncoded, instead?

10 |1200

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

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.