以下是我的App Engine端点。我将它注释为ApiMethod.HttpMethod.GET
,因为我希望能够通过浏览器进行get调用。这个类本身有几十种可以理解的方法。其中一些使用POST
。但getItems
注明GET
。当我尝试通过浏览器调用的URL,我得到一个405错误App Engine端点:此URL不支持HTTP方法GET
Error: HTTP method GET is not supported by this URL
代码:
@Api(name = "myserver",
namespace = @ApiNamespace(ownerDomain = "thecompany.com", ownerName = "thecompany", packagePath = ""),
version = "1", description = "thecompany myserver", defaultVersion = AnnotationBoolean.TRUE
) 公共类MYSERVER {
@ApiMethod(name = "getItems", httpMethod = ApiMethod.HttpMethod.GET)
public CollectionResponse<Item> getItems(@Named("paramId") Long paramId) {
…
return CollectionResponse.<Item>builder().setItems(ItemList).build();
}
}
这不是本地主机,它是为真正的服务器。也许我错误地形成了网址。我曾尝试过几个网址,例如
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
为什么现在格式化SO代码非常困难?它曾经很容易。他们曾经“修复”他们需要将它改回来。 – learner
您可以使用api资源管理器找出您是否使用了正确的网址。转到https://yourprojectid.appspot.com/_ah/api/explorer。另外,如果您不打算使用google javascript api客户端,则应该在'@ ApiMethods'中添加'path = ...',这样您就可以确定实际的路径。 – konqi