Sign In Register

How can we help you today?

Start a new topic
Answered

REST API add versus update

Started looking at/playing with the new REST game API today...

Am I correct is stating that if I want to send in a Leaderboard (for example) entry, I need to know whether it exists already in the current game configuration (because of the POST vs PUT url format differences) ?


If I try to POST it again, it will tell me that it's name is not unique 

If I try to PUT it (without it existing already), it will tell me that the id does not exist.


So essentially, I need to try a GET (or pull the whole game config ahead of time) and determine if game element is already present (for that id) first ....keerect?


thanks in advance!!


Best Answer

Hi Jeff,


Yes you would use a POST request to insert a new piece of configuration, a PUT request would be used to update an existing piece of game configuration. To answer your last question yes you would need to GET the game configuration or have prior knowledge of what is already in place in the game. When getting the game config through the REST API you can set "full" to false to return a summarized version of the game configuration. For example the events array would look like this.

 

 "~events": [
    {
      "@ref": "/~events/event01"
    },
    {
      "@ref": "/~events/event02"
    },
]

  

With "full" set to true it would include , name, description, shortCode etc... I hope this helps, if you have any further questions just let us know.


Thanks,

Liam

1 Comment

Answer

Hi Jeff,


Yes you would use a POST request to insert a new piece of configuration, a PUT request would be used to update an existing piece of game configuration. To answer your last question yes you would need to GET the game configuration or have prior knowledge of what is already in place in the game. When getting the game config through the REST API you can set "full" to false to return a summarized version of the game configuration. For example the events array would look like this.

 

 "~events": [
    {
      "@ref": "/~events/event01"
    },
    {
      "@ref": "/~events/event02"
    },
]

  

With "full" set to true it would include , name, description, shortCode etc... I hope this helps, if you have any further questions just let us know.


Thanks,

Liam

Login to post a comment