Reputation: 11780
Following is my App Engine Endpoint. I annotate it as ApiMethod.HttpMethod.GET
because I want to be able to make a get call through the browser. The class itself has a few dozen methods understandably. Some of them using POST
. But getItems
is annotated with GET
. When I try to call the url through a browser, I get a 405 error
Error: HTTP method GET is not supported by this URL
The code:
@Api(name = "myserver",
namespace = @ApiNamespace(ownerDomain = "thecompany.com", ownerName = "thecompany", packagePath = ""),
version = "1", description = "thecompany myserver", defaultVersion = AnnotationBoolean.TRUE
) public class myserver {
@ApiMethod(name = "getItems", httpMethod = ApiMethod.HttpMethod.GET)
public CollectionResponse<Item> getItems(@Named("paramId") Long paramId) {
…
return CollectionResponse.<Item>builder().setItems(ItemList).build();
}
}
This is not for localhost, it’s for the real server. Perhaps I am forming the url incorrectly. I have tried a few urls such as
https://thecompanymyserver.appspot.com/_ah/spi/com.thecompany.myserver.endpoint.myserver.getItems/v1/paramId=542246400
https://thecompanymyserver.appspot.com/_ah/spi/myserver/NewsForVideo/v1/542246400
Upvotes: 0
Views: 1104
Reputation: 2595
The proper path for this is /_ah/api/myserver/1/getItems. /_ah/spi refers to the backend path, which only takes POST requests of a different format.
Side note: API versions are typical "vX" instead of just "X".
Upvotes: 1
Reputation: 5227
You can use the api explorer to find out whether you're using the correct url. Go to
https://yourprojectid.appspot.com/_ah/api/explorer
this works on the devserver as well:
http://localhost:8080/_ah/api/explorer
Also if you're not planning to use the google javascript api client you should add path="..."
to your @ApiMethod
s, so you are sure about what the path actually is.
Upvotes: 0