Ruby cURL POST 请求未通过
Ruby cURL POST Request not going through
我正在使用 Paw,这是一个用于测试 REST 请求的应用程序。我有以下使用该应用程序的请求,但需要将其更改为使用 cURL 以在我的 ruby on rails 应用程序中使用。
POST /rest/api/latest/result/TRUNKDEVQAUNIT-TESTANDRGITBUILDDEV-12/comment HTTP/1.1
Content-type: application/json
Accept: application/json
Authorization: Basic dWkud29ya2JvdDpFVmgzUFQ0dEch
Cookie: JSESSIONID=C851F60AFB4A83F12753B9CCBC745093
Host: bamboo10.com
Connection: close
User-Agent: Paw/2.2.5 (Macintosh; OS X/10.10.5) GCDHTTPRequest
Content-Length: 32
{"content":"here is a comment, for testing purposes“}
我认为它应该看起来像这样,但它不起作用。出于安全原因,我没有添加真实的用户名和密码(或主机)。任何帮助将非常感激。谢谢!
`curl -X POST -u username:password --data {"body": "This is a comment, for testing purposes"} -H "Accept: application/json" -H "Content-type: application/json" https://bamboo.com/rest/api/latest/result/TRUNKDEVQAUNIT-TESTANDRGITBUILDDEV-12/comment`
经过一段时间后,我找到了正确的做法。看来我在数据前后缺少一个 ' ,并且将 json 元素更改为 content
而不是 body
curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -u username:password -d '{"content": "This is a comment, for testing purposes"}' https://bamboo10.com/rest/api/latest/result/TRUNKDEVQAUNIT-TESTANDRGITBUILDDEV-12/comment
我正在使用 Paw,这是一个用于测试 REST 请求的应用程序。我有以下使用该应用程序的请求,但需要将其更改为使用 cURL 以在我的 ruby on rails 应用程序中使用。
POST /rest/api/latest/result/TRUNKDEVQAUNIT-TESTANDRGITBUILDDEV-12/comment HTTP/1.1
Content-type: application/json
Accept: application/json
Authorization: Basic dWkud29ya2JvdDpFVmgzUFQ0dEch
Cookie: JSESSIONID=C851F60AFB4A83F12753B9CCBC745093
Host: bamboo10.com
Connection: close
User-Agent: Paw/2.2.5 (Macintosh; OS X/10.10.5) GCDHTTPRequest
Content-Length: 32
{"content":"here is a comment, for testing purposes“}
我认为它应该看起来像这样,但它不起作用。出于安全原因,我没有添加真实的用户名和密码(或主机)。任何帮助将非常感激。谢谢!
`curl -X POST -u username:password --data {"body": "This is a comment, for testing purposes"} -H "Accept: application/json" -H "Content-type: application/json" https://bamboo.com/rest/api/latest/result/TRUNKDEVQAUNIT-TESTANDRGITBUILDDEV-12/comment`
经过一段时间后,我找到了正确的做法。看来我在数据前后缺少一个 ' ,并且将 json 元素更改为 content
而不是 body
curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -u username:password -d '{"content": "This is a comment, for testing purposes"}' https://bamboo10.com/rest/api/latest/result/TRUNKDEVQAUNIT-TESTANDRGITBUILDDEV-12/comment