Google云端终结点生成的Java API出现HTTP 400错误。

huangapple go评论91阅读模式
英文:

Google cloud endpoints generate Java api HTTP 400 error

问题

嗨,我正在尝试使用这个文档go-endpoints开发一个REST API。

我可以在本地和应用引擎上测试我的应用程序。

但是我无法创建一个Java客户端来在Android设备上使用它,因为某种原因我得到了一个错误信息:

> HTTP 400 无法解码JSON对象

在这个命令上:

  GO_SDK/endpointscfg.py gen_client_lib java MY_FILE_NAME

这是完整的堆栈跟踪:

    mik@mik-Aspire-S3:~/go-programs/src/cloudEndPoints/app$ $HOME/go_appengine/endpointscfg.py gen_client_lib java ballota_test
Traceback (most recent call last):
  File "/home/mik/go_appengine/endpointscfg.py", line 133, in <module>
    run_file(__file__, globals())
  File "/home/mik/go_appengine/endpointscfg.py", line 129, in run_file
    execfile(_PATHS.script_file(script_name), globals_)
  File "/home/mik/go_appengine/google/appengine/tools/endpointscfg.py", line 561, in <module>
    main(sys.argv)
  File "/home/mik/go_appengine/google/appengine/tools/endpointscfg.py", line 557, in main
    args.callback(args)
  File "/home/mik/go_appengine/google/appengine/tools/endpointscfg.py", line 458, in _GenClientLibCallback
    args.build_system)
  File "/home/mik/go_appengine/google/appengine/tools/endpointscfg.py", line 335, in _GenClientLib
    build_system, client_name)
  File "/home/mik/go_appengine/google/appengine/tools/endpointscfg.py", line 366, in _GenClientLibFromContents
    raise ServerRequestException(error)
__main__.ServerRequestException: 与URL通信时发生HTTP 400(错误请求)错误: https://google-api-client-libraries.appspot.com/generate。详情:JSON格式错误:无法解码JSON对象

更新

我尝试构建这个示例项目tictactoe作为一个Java客户端,我得到了相同的错误。

英文:

Hey im trying to develop a rest API by using this doc go-endpoints

I can test my app locally and on the app engine .

But i cant create a Java client in order to consume it on android device,
for some reason I'm getting an

> HTTP 400 No JSON object could be decoded

on this command

  GO_SDK/endpointscfg.py gen_client_lib java MY_FILE_NAME

This is the full stack trace

    mik@mik-Aspire-S3:~/go-programs/src/cloudEndPoints/app$ $HOME/go_appengine/endpointscfg.py gen_client_lib java ballota_test
Traceback (most recent call last):
  File "/home/mik/go_appengine/endpointscfg.py", line 133, in <module>
    run_file(__file__, globals())
  File "/home/mik/go_appengine/endpointscfg.py", line 129, in run_file
    execfile(_PATHS.script_file(script_name), globals_)
  File "/home/mik/go_appengine/google/appengine/tools/endpointscfg.py", line 561, in <module>
    main(sys.argv)
  File "/home/mik/go_appengine/google/appengine/tools/endpointscfg.py", line 557, in main
    args.callback(args)
  File "/home/mik/go_appengine/google/appengine/tools/endpointscfg.py", line 458, in _GenClientLibCallback
    args.build_system)
  File "/home/mik/go_appengine/google/appengine/tools/endpointscfg.py", line 335, in _GenClientLib
    build_system, client_name)
  File "/home/mik/go_appengine/google/appengine/tools/endpointscfg.py", line 366, in _GenClientLibFromContents
    raise ServerRequestException(error)
__main__.ServerRequestException: HTTP 400 (Bad Request) error when communicating with URL: https://google-api-client-libraries.appspot.com/generate.  Details: ill-formed JSON: No JSON object could be decoded

UPDATE

I tried to built this sample project tictactoe as a Java client and i got the same error

答案1

得分: 0

我在crhym3的云端点示例中发布了一个问题,他帮助我理解了我的错误。

我的错误是我尝试使用错误的URL地址创建客户端。

这是错误的地址。

https://winged-precept-894.appspot.com 这将返回404错误

而这是正确的发现API URL。

https://winged-precept-894.appspot.com/_ah/api/discovery/v1/apis/myapp/v1/rpc

所以这是一个URL错误,而不是一个JSON导向的错误。

英文:

I posted an issue in
crhym3 cloud endpoints example and he helped my to understand my error.

My mistake was that i tried to create the client with the wrong URL address .

This is the wrong address.

https://winged-precept-894.appspot.com this will return 404

And this is the correct discovery api URL.

https://winged-precept-894.appspot.com/_ah/api/discovery/v1/apis/myapp/v1/rpc

So it was a url error and not a Json oriented error .

huangapple
  • 本文由 发表于 2015年3月9日 22:14:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/28944144.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定