質問

I'm using Google App Engine and Google Cloud Endpoints to communicate between my Android app (frontend) and the webservice (backend) that runs in the cloud. But I wonder about the URL's used for GET and POST.

Imagine you have a list of notes on the server each with a caption and an id. According to CRUD (create, updated, delete), the HTTP/HTTPS calls should look like that:

Get all notes:

GET http://domain.eu/notes

Get a specific note by it's id (let's say 123):

GET http://domain.eu/notes/id

and so on. But Google uses a different pattern. For instance if you use the API explorer you get calls like this:

GET https://domain/_ah/api/notesEndpoint/v1/notesdata

Question: Is there a general way to get a call for listing all notes? According to the annotations in the source code it should be somewhat like /notes or /notes.listNodes I simply don't understand how Google constructs the URL's

役に立ちましたか?

解決

Google Cloud Endpoints use the API-Explorer system.

/_ah/api is defined for the API Explorer, you can't change it. notesEndpoint is the name of your Api, and v1 the version you define. notesdata is the name of the method. You can override the path by annotation.

Example, to access to the notes through

domain/_ah/api/notesEndpoint/v1/notes

You have to make this method :

@ApiMethod(
    name = "notes.listNodes",
    path = "notes",
    httpMethod = HttpMethod.GET
 )
 public List<Foo> notesdata() {
    return myList;
 }

(a link to the documentation : DOC)

For information, with this system, you can explore your API with this URL :

GET http://domain.eu/_ah/api/explorer

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top