ank*_*kur 4 java google-app-engine curl jdo google-cloud-endpoints
我正在尝试使用 HTTP GET 方法:
curl http://localhost:8888/_ah/api/birra/v1/beer
Run Code Online (Sandbox Code Playgroud)
它返回给我当前的列表,这是正常的和预期的:
{
"items" : [ {
"id" : "1",
"beerName" : "Bud"
}, {
"id" : "2",
"beerName" : "Steve"
}, {
"id" : "3",
"beerName" : "Ankur"
} ]
}
Run Code Online (Sandbox Code Playgroud)
但是当我像这样执行 HTTP POST 时:
curl -X POST -H "Content-Type: application/json" -H "Accept:application/json" -d "{\"beerName\": \"asdf\"}" http://localhost:8888/_ah/api/birra/v1/beer
Run Code Online (Sandbox Code Playgroud)
它给我的错误是:
{
"error" : {
"message" : "javax.jdo.JDOFatalInternalException: The key value passed to construct a SingleFieldIdentity of type \"class javax.jdo.identity.LongIdentity\" for class \"class com.samples.Beer\" is null.\nNestedThrowables:\norg.datanucleus.exceptions.NucleusException: The key value passed to construct a SingleFieldIdentity of type \"class javax.jdo.identity.LongIdentity\" for class \"class com.samples.Beer\" is null.",
"code" : 503,
"errors" : [ {
"domain" : "global",
"reason" : "backendError",
"message" : "javax.jdo.JDOFatalInternalException: The key value passed to construct a SingleFieldIdentity of type \"class javax.jdo.identity.LongIdentity\" for class \"class com.samples.Beer\" is null.\nNestedThrowables:\norg.datanucleus.exceptions.NucleusException: The key value passed to construct a SingleFieldIdentity of type \"class javax.jdo.identity.LongIdentity\" for class \"class com.samples.Beer\" is null."
} ]
}
}
Run Code Online (Sandbox Code Playgroud)
我目前正在研究 Google Cloud Endpoints 示例,该示例提供于: Google Developers 的 Cloud Endpoints
我正在使用 Eclipse IDE 和在 Jetty 上运行的服务器本地主机。
有什么解决办法吗?
使用双引号而不是单引号。当您从 Windows 运行时,会发生此类错误。这就是为什么它说couldn't resolve host。
curl -H "Content-Type: application/json" -d "{\"beerName\": \"bud\"}" http://localhost:8888/_ah/api/birra/v1/beer
Run Code Online (Sandbox Code Playgroud)