英文:
500 internal server error for Curl command for POST method(for JSON ) of restful web service using Go
问题
有一个名为countries.go的文件,它导入了github.com/ant0ine/go-json-rest/rest包。
参考代码来自https://gowalker.org/github.com/ant0ine/go-json-rest#countries。
Countries部分:演示POST DELETE等操作。
当我尝试使用以下命令:
curl -i -d '{"Code":"FR","Name":"France"}' http_URL
它返回:
{
"Error": "invalid character '\' looking for beginning of value"
}
我已经使用了上述给出的包。似乎请求中的request.go文件中的DecodeJsonPayload()方法,在实现JSON的unmarshal()时出现了内部服务器错误。
我无法纠正这个问题。希望能得到帮助。
英文:
There is a file named countries.go
It imports package github.com/ant0ine/go-json-rest/rest.
referred code from
https://gowalker.org/github.com/ant0ine/go-json-rest#countries
Countries section:Demo of POST DELETE etc
When i try to use command
curl -i -d '{"Code":"FR","Name":"France"}' http_URL
It gives
{
"Error": "invalid character '\'' looking for beginning of value"
}
I have used the package given above .It seems the method in the request.go given as DecodeJsonPayload() ,which implements unmarshal() for JSON , have internal server error.
I am unable to correct that.Help appreciated
答案1
得分: 1
我成功地在Windows上使用curl复制了你的问题。
请使用以下curl命令代替:
curl -i -d "{\"Code\":\"FR\",\"Name\":\"France\"}" http_URL
相关的SO问题:https://stackoverflow.com/questions/4514199/how-to-send-double-quote-in-d-parameter-for-curl-exe
英文:
I managed to duplicate your problem with curl on Windows.
Use the following curl command instead:
curl -i -d "{\"Code\":\"FR\",\"Name\":\"France\"}" http_URL
A related SO question: https://stackoverflow.com/questions/4514199/how-to-send-double-quote-in-d-parameter-for-curl-exe
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论