dynamokaj
dynamokaj

Reputation: 481

How to call Google Cloud Endpoints RPC API on localhost?

EDIT I posted an issue on this and it should be fixed in release 1.9.16 of Google AppEngine SDK. https://code.google.com/p/googleappengine/issues/detail?id=11414


I am developing a service using Google Cloud Endpoints.

Both the REST and the RPC API works great when I deploy it on App Engine. However the strange thing is, when I test the service locally (localhost), the REST calls works fine, but I am having trouble with calls using RPC.

My method signature in the backend is:

@ApiMethod(name = "user.updateprofile", httpMethod = HttpMethod.POST)
public UserProfileDto updateProfile(@Named("sessionToken") String sessionToken, UserProfileDto profile) throws UnauthorizedException { return profile; }

For simplicity I am just returning the UserProfileDto directly.

I have tried to execute the following request locally:

POST http://localhost:4567/_ah/api/rpc?prettyPrint=false
Content-Type: application/json-rpc
Accept: application/json-rpc
{
"method": "mobilebackend.user.updateprofile",
"id": "gtl_1",
"jsonrpc": "2.0",
"params": {
    "sessionToken": "12345",
    "resource": {
      "username": "foo",
      "userPrivate": true
    }
},
"apiVersion": "v1"
}

When I set a breakpoint in the updateProfile method, I see that the sessionToken is correctly 12345 however the username field is null and the userPrivate field is false even though I specified it as true. The instance of UserProfileDto (profile) is not null.

The problem is that it fails to inject the values into the fields of the DTO when using RPC calls localhost. When I test it on the deployed version it works fine, and when I use REST calls it works both on localhost and when deployed on App Engine.

When I change the url in the above request to target the deployed version of my application on app engine it works just fine. https://<app-name>.appspot.com/_ah/api/rpc?prettyPrint=false

I start the service on localhost using:

mvn appengine:devserver

Do I miss some configuration in order to call the Cloud Endpoints RPC methods localhost? Or is it not supported?

I should notice that I have also tried with the auto-generated iOS client library which is using RPC and it also fails with the same error as the service fails to inject the values into the fields of the DTO object.

Upvotes: 1

Views: 778

Answers (1)

dynamokaj
dynamokaj

Reputation: 481

I have tested release 1.9.17 of Google AppEngine SDK and can confirm that using objects in RPC POST requests now works fine.

Upvotes: 1

Related Questions