0

We are integrating Google App State into our web based game using Google's API discovery service. Our test code looks like this:

gapi.client.load('appstate','v1',function(response) {
  var request = gapi.client.appstate.states.update({ stateKey: 0 });
  request.execute(function(result) { console.log(result); });
});

I always get back an HTTP 400 with the message "The update request does not contain any data.". This makes sense since I'm not passing any data, the problem is that I have no idea how to pass the data (aka state) and I can't find any documentation on how to do it. I tried passing some data along with the stateKey

{ stateKey: 0 , data: <some-base64-encoded-data> }

But this still fails with the same message.

After inspecting the library's minified code I'm starting to suspect this feature is still unimplemented.


UPDATE (after doing some more experiments)

I also tried using gapi.client.request like this:

  var request = gapi.client.request({
      'path': '/appstate/v1/states',
      'params': { 'stateKey': '0' },
      'method': 'PUT',
      'body': {
        'kind': 'appstate#updateRequest', 
        'data': 'ZGF0YQ=='
      }
  });

But I get a 404 and I think it's because this method passes request parameters in the &stateKey=0 style. On the other hand if I use 'path': '/appstate/v1/states/0' I get a conflict response which is what I was expecting.

Correct me if I'm wrong but I'm starting to believe that the problem is due to inconsistencies between Google's different web APIs which they are now trying to coalesce into a single interface.

Juan Campa
  • 1,181
  • 2
  • 14
  • 20

1 Answers1

0

In your initial Discovery-based method, you need to pass the data in a parameter named 'resource.' Here is the Discovery document for appstate/v1: https://www.googleapis.com/discovery/v1/apis/appstate/v1/rpc

J P
  • 26
  • 1