question

banana avatar image
banana asked

,/Server/GrantItemsToUsers validation errors?

,

Hi, is there something wrong with the following request?

server.GrantItemsToUsers({
            ItemGrants: [{
                PlayFabId: currentPlayerId,
                ItemId: lootBoxEarnedItemId,
                Data: referenceItem.CustomData
            }]
        });

It produces the following error on playfab:

{
                "Level": "Error",
                "Message": "PlayFab API request error",
                "Data": {
                    "api": "/Server/GrantItemsToUsers",
                    "request": {
                        "ItemGrants": [
                            {
                                "PlayFabId": "XXXXX",
                                "ItemId": "lootbox.6",
                                "Data": "{\"droptable\":\"Loot Box 6\",\"type\":\"6\"}"
                            }
                        ]
                    },
                    "result": null,
                    "apiError": {
                        "code": 400,
                        "status": "BadRequest",
                        "error": "InvalidParams",
                        "errorCode": 1000,
                        "errorMessage": "Invalid input parameters",
                        "errorHash": null,
                        "errorDetails": {
                            "PlayFabId": [
                                "The PlayFabId field is required."
                            ],
                            "ItemId": [
                                "The ItemId field is required."
                            ]
                        }
                    }
                }
            }

If I modify the request to include the keys it says it's missing, I get more errors:

{
                "Level": "Error",
                "Message": "PlayFab API request error",
                "Data": {
                    "api": "/Server/GrantItemsToUsers",
                    "request": {
                        "PlayFabId": "XXXXX",
                        "ItemId": "lootbox.6",
                        "Data": "{\"droptable\":\"Loot Box 6\",\"type\":\"6\"}",
                        "ItemGrants": [
                            {
                                "PlayFabId": "XXXXX",
                                "ItemId": "lootbox.6",
                                "Data": "{\"droptable\":\"Loot Box 6\",\"type\":\"6\"}"
                            }
                        ]
                    },
                    "result": null,
                    "apiError": {
                        "code": 400,
                        "status": "BadRequest",
                        "error": "InvalidParams",
                        "errorCode": 1000,
                        "errorMessage": "Invalid input parameters",
                        "errorHash": null,
                        "errorDetails": {
                            "ItemGrants[0].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.

1 Answer

·
brendan avatar image
brendan answered

The first form, with the PlayFabId and ItemId in the ItemGrant object is correct. Two things, though: First, remove the period from the ItemId in your catalog - there was an issue with periods in Item IDs in the past (I'll make sure we have a bug open on that). Second, what's the actual PlayFab ID you passed in? What happens if you try making the call via Postman?

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.