1

编辑 2:我使用 wget 让它工作。这是 wget 命令:

wget --no-check-certificate --header='Host: [hostname]' --header 'Connection: keep-alive' --header 'Authorization: Basic [user:pass(Base64)]' --header 'Content-Type: application/json' --header 'Accept: application/json' --post-data='{"slug":"test", "name":"test"}' https://[hostname]/rest/api/1.0/projects/[projectName]/repos/

根据文档,这似乎是可能的。不过,我似乎无法让它发挥作用。有没有人设法完成这项工作?

编辑1:

我实际上设法通过代理手动创建一个 http 请求来创建一个 repo。这是有效的请求:

POST /rest/api/1.0/projects/[Project Name]/repos HTTP/1.1
Host: [hostname]
Connection: keep-alive
Authorization: Basic [user:pass (Base64)]
Content-Length: 29
Cache-Control: max-age=0
Origin: https://[hostname]
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1
Content-Type: application/json
Accept: application/json
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

{"slug":"test","name":"test"}

但是当我尝试使用 curl 来模仿它时,我无法让它工作。这是卷曲请求:

curl -k -X POST -H "Host: [hostname]" -H "Connection: keep-alive" -H "Authorization: [user:pass (Base64)]" -H  "Content-Length: 29" -H "Cache-Control: max-age=0" -H "Origin: https://[hostname]" -H "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1" -H "Content-Type: application/json" -H "Accept: application/json" -H "Accept-Encoding: gzip,deflate,sdch" -H "Accept-Language: en-US,en;q=0.8" -H "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3" --data {"slug":"test", "name":"test"} https://[hostname]/rest/api/1.0/projects/[projectName]/repos/

我无法说出第二个请求中 Curl 没有提供的 Stash 期望什么。有任何想法吗?

4

1 回答 1

1

我使用 wget 让它工作。这是 wget 命令:

wget \ --no-check-certificate \ --header='Host: [hostname]'\ --header 'Connection: keep-alive' \ --header 'Authorization: Basic [user:pass(Base64)]' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --post-data='{"slug":"test", "name":"test"}' \ https://[hostname]/rest/api/1.0/projects/[projectName]/repos/

于 2016-12-04T19:16:07.153 回答