question

choi dong geun avatar image
choi dong geun asked

UpdateUserInventoryItemCustomData error

"ExecutionResult": {
        "ExecutionResult": {
            "ExecutionTimeSeconds": 0.0378921,
            "ProcessorTimeSeconds": 0.015625,
            "MemoryConsumedBytes": 70672,
            "HttpRequestsIssued": 0,
            "APIRequestsIssued": 2,
            "Revision": 4,
            "FunctionName": "onbuyitem",
            "Error": {
                "Message": "The script called a PlayFab API, which returned an error. See the Error logs for details.",
                "Error": "CloudScriptAPIRequestError",
                "StackTrace": "Error\n    at Object.server_request (Script:180:24)\n    at Object.server.UpdateUserInventoryItemCustomData (Script:624:90)\n    at handlers.onbuyitem (3F4CF-main.js:96:20)\n    at Object.invokeFunction (Script:116:33)"
            },
            "Logs": [
                {
                    "Message": "PlayFab API request error",
                    "Data": {
                        "apiError": {
                            "errorMessage": "Invalid input parameters",
                            "errorDetails": null,
                            "errorCode": 1000,
                            "errorHash": null,
                            "status": "BadRequest",
                            "error": "InvalidParams",
                            "code": 400
                        },
                        "request": {
                            "ItemInstanceId": "DE79E90148E119A8",
                            "PlayFabId": "D4056A9087432FCF",
                            "Data": {
                                "stat": "{\"grade\":1, \"key\":7}"
                            }
                        },
                        "result": null,
                        "api": "/Server/UpdateUserInventoryItemCustomData"
                    },
                    "Level": "Error"
                }
            ]
        }

As you can see above, there's an error.
I was going to put the value in the custom data of the item.
Error is coming out, but the value is inserted as normal in custom data.
I care about errors to ignore. What's wrong with this?

10 |1200

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

Seth Du avatar image
Seth Du answered

If I use the instance ID and PlayFab ID you have provided above, this issue can be reproduced and the same error is returned in the callback. Meanwhile If I replace the data with the correct PlayFab ID with existing instance ID in the inventory, I cannot produce this issue.

Meanwhile, I don’t think it is caused by the “Data” field, because it can be a manual input KVP with string value like you have provided, or a JS object. Both should work fine. Hence, I suggest you double-checking the Instance ID and PlayFab ID and make sure the item is in the inventory.

Here is my testing function:

handlers.testtest1 = function (args, context)
{
    var stat = {
        "grade":1,
        "key":7
    };
    var request = {
        "ItemInstanceId": "xxxxxxxxx",
        "PlayFabId": "xxxxxxxxxxxx",
        "Data": { stat }
        };
            
    var result = server.UpdateUserInventoryItemCustomData(request);
    return result;
}


10 |1200

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

madmojoman avatar image
madmojoman answered

It says you have invalid input parameters for the request sent to update the data. I would verify your request data. It looks to me like you're probably passing in 1 and 7 instead of "1" and "7" in quotes as strings, though.

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.