Developers

Flat
API Fails To Find Game
User: LordAshes
Date: 1/22/2016 10:12 pm
Views: 2589
Rating: 0

I have successfully used the API to generate a session and list the contents of the user's orders. However, when I try to use the API to get the details of a game, it keeps returning a 404 error indicating that the game ID cannot be found.

I have double checked the ID by reading from the order and also doing a general list of all games and reading the ID from that list. Both the ID of the game in the order and the ID of the game in the games list match.

I am using the request (with session_id provided):


/api/game/xxx

Where the xxx is the ID of the game (i.e. the 37 or whatever it is character game code). I saw a note to be careful because IDs are case sensitive but the ID shows up as all caps when read.

I assume the game does not need to be published in order for the details to be fetched, correct?

Re: API Fails To Find Game
JT
User: JT
Date: 1/22/2016 10:55 pm
Views: 150
Rating: 0

A game's id cannot be fetched via receipt data, which as I write that I realize is likely a flaw in the API. But, it also means that whatever data you are using is wrong, and explains why it is failing. 

You can fetch a users list of games from:

/api/user/XXX/games

Or you could fetch their list of designers:

/api/user/XXX/designers

And then fetch the list of games from a designer:

/api/designer/XXX/games

Or if you go into the game editor in our UI, you can get a game's ID from the URL, and then fetch the game directly:

/api/game/XXX

Also the session isn't the culprit, because you can fetch public info about a game without even using a session. For example: https://www.thegamecrafter.com/api/game/9C3B02AE-2052-11E5-8005-CBC3ADC92F5F

Nope, a game doesnt need to be published to read it.

I'll make a note to add the ability to fetch a game's ID and relationship from the order item data next week.

Re: API Fails To Find Game
JT
User: JT
Date: 1/25/2016 9:55 am
Views: 1242
Rating: 0

If you add _include_relationships=1 on your request of receipts

https://www.thegamecrafter.com/api/user/XXX/receipts?_include_relationships=1

You'll get a relationship called "items". Note that you can also get the items relationship from the receipt directly if you know the receipt ID or URL (https://www.thegamecrafter.com/api/receipt/XXX?_include_relationships=1)

There then you can fetch that, again with _include_relationships=1

https://www.thegamecrafter.com/api/receipt/XXX/items?_include_relationships=1

That will give you a relationship called "sku". And if you fetch that relationship it will turn into the appropriate object type (game, part, etc), depending upon what was in the order.

https://www.thegamecrafter.com/api/sku/XXX

PreviousNext