2012-08-31 45 views
1

編輯2: 我知道它使用wget工作。這裏是wget命令:通過Rest API創建Stash回購?

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請求來創建回購。這是請求的工作:

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 -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/ 

我不能告訴藏匿期待的是沒有被捲曲在第二請求中提供。有任何想法嗎?

+0

你能更具體地說明什麼不起作用嗎?如果有的話可能是錯誤信息? – R0MANARMY

+0

@nweiler你應該發佈你的編輯1 /編輯2作爲你自己問題的答案。 – mike

+0

@mike好點。完成。 – nweiler

回答

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/