question

Luke Stafford avatar image
Luke Stafford asked

Grant Items to Character (Internal Server Error)

Having problems granting items to characters so tried it via the web api, getting this response, is something broken here?

API Call Results

{
 "code": 500,
 "status": "InternalServerError",
 "error": "InternalServerError",
 "errorCode": 1110,
 "errorMessage": "An unexpected error occured while processing the request.",
 "errorHash": "e4d2a901108b373e43f18b78198a5b9a",
 "errorDetails": {
  "RequestID": [
   "047e185ea08a4d419f384495c478cb2e"
  ]
 },
 "CallBackTimeMS": 491
}
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

According to the error log, you're passing in the PlayFab ID and Character ID, but no Item IDs. I'll open a bug on that, to either have ItemIds made a required parameter, or just return a detailed error for that situation.

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.

erik-wagner avatar image erik-wagner commented ·

Hi Brendan, I am running into a similar issue, though I'm certain it is a problem on my syntax. Here is snippet of the cloudscript I'm trying to run; when I run it I get a status 500 back. Do I not have the ItemIds in the correct format? Thanks for any help on this!

var grantCharacter = server.GrantCharacterToUser({
      PlayFabId: currentPlayerId,
      CharacterName: "My Empire",
      CharacterType: "Empire"
    });
var charId = grantCharacter.CharacterId;
var grantItems = server.GrantItemsToCharacter({
      PlayFabId: currentPlayerId,
      CharacterId: charId,
      ItemsIds: ["Planet", "Slot"]
    });
0 Likes 0 ·
Luke Stafford avatar image
Luke Stafford answered

Thanks Brendan, to be honest I have been passing ItemIds (although maybe there has been some error in my syntax) and getting the same error. I decided to try it via the webapi and got the above. according to the web api the itemid isn't a required param (nor the catalogue), so as you say maybe this should return something more informative.

I've now tinkered more with the webapi, and even when adding the itemID, while not reporting any errors, it still does not grant the item and the result is false. The Item I am trying to add is in a 2nd catalogue and when I include the optional catalogue it grants the item successfully.

I guess the optional params are not so optional :)

I will try and fix my cloud script now, but for clarity here are the API call results.

Thank you for the help :)

without the catalogue:

API Call Results

{
 "code": 200,
 "status": "OK",
 "data": {
  "ItemGrantResults": [
   {
    "PlayFabId": "********",
    "CharacterId": "4D168D1FE52C7FEC",
    "Result": false,
    "ItemId": "56",
    "UnitPrice": 0
   }
  ]
 },
 "CallBackTimeMS": 1266
}

with the catalogue:

API Call Results

{
 "code": 200,
 "status": "OK",
 "data": {
  "ItemGrantResults": [
   {
    "PlayFabId": "**********",
    "CharacterId": "4D168D1FE52C7FEC",
    "Result": true,
    "ItemId": "56",
    "ItemInstanceId": "920FD4904A3F9FF3",
    "PurchaseDate": "2017-06-18T20:38:18.581Z",
    "CatalogVersion": "DB4D Clothing",
    "DisplayName": "Blue Jeans",
    "UnitPrice": 0
   }
  ]
 },
 "CallBackTimeMS": 1243
}
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.

brendan avatar image brendan commented ·

The items to be granted should be required in the API call, since there's no purpose in calling it without any Item IDs - that's the bug I've opened. But the CatalogVersion is definitely not required - as stated in the docs, if you don't specify one, the items must be in the primary catalog for the title. If you need something from another Catalog Version, you do need to specify that - but that would not then make the parameter required.

0 Likes 0 ·
Luke Stafford avatar image Luke Stafford brendan commented ·

I must have missed the part in the docs about the other catalog. I have it working correctly now. Basically I was adding the itemID but not the catalog in the cloud-script, and then when testing the web api, I only provided the data 'required' to check it was working at all.

So yes, clear and working now, needs the Catalog (if its not from the primary cat) and must 'obviously' have the itemID.

Thanks for the help and clarification.

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.