编辑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/
我无法分辨Stash在第二个请求中没有提供的内容。有什么想法吗?
答案 0 :(得分: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/