Sign In Register

How can we help you today?

Start a new topic
Solved

NoSQL REST API (v2) Issues

I'm struggling to use the (new) NoSQL REST API. 


#1). the API base URL does't appear to conform to the structure 

specified in the docs:


"

The base URL is not fixed but is dependent on the specific runtime cluster that your game is assigned to and the game stage. The structure of the base URL will always conform to this schema: https://[apiKey].cluster.[stage].gamesparks.net

"


Running 

GET https://config-beta.gamesparks.net/restv2/game/W************/endpoints

 yields 

{
  "previewNosql": "https://gsp-muw000-cluster.gamesparks.net",
  "previewElasticSearch": "https://gsp-muw000-es.gamesparks.net"
}

clearly not the same form as spec'd above.

(using basic auth)


#2). All requests to the previewNosql base api result in 404s


Running  

GET https://gsp-muw000-cluster.gamesparks.net/restv2/game/W***********/mongo/collection

 or any of the other requests listed here

returns 

{
  "message": "URI is not absolute"
}

 with just the basic auth header set.


I've tried using 

https://W307563n5YA9-cluster.preview.gamesparks.net

as the base as is done if you enter your credentials on this page and hit the try buttons that appear on some of the methods, but all requests result in 404s (and a quote from Portal). 


I've also tried authorizing using X-GSAccessToken with the same results. 


Any help would be useful.

Note that I'm able to use the REST v1 API without problems. 


Hi Jordan,


You need to get the Json Web Token here. You can get that for nosql with a GET request to https://auth.gamesparks.net/restv2/auth/game/{apikey}/jwt/nosql


The URL is built with the peviewNosql value returned from the endpoints GET call to https://config-beta.gamesparks.net/restv2/game/{apikey}/endpoints


You'll need to set the header value of X-GS-JWT to be the returned token that you got from the request above. Now when you send the request you should get a response. You don't need to use basic auth here.


We can test this now with a simple get call to return all of the collections in your game. The following URL should do this for you with a GET request. 

https://gsp-aeu000-cluster.gamesparks.net/restv2/game/{apikey}/mongo/collections


Try that and let me know if you have any further questions. I've edited your original post to obscure your api key for security reasons.


Regards,

Liam





Thanks! That X-GS-JWT was what I was missing. All set now. 


Hi Jordan,


No problem. Glad to hear it's working for you now !


Regards,

Liam

Login to post a comment