Reputation: 1190
Edit 2: I got it working using wget. Here is the wget command:
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/
Based on the documentation it seems like it may be possible to this. I cannot seem to make it work, though. Has anyone managed to make this work?
Edit 1:
I actually managed to create a repo by manually creating an http request through a proxy. Here is the request that worked:
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"}
But when I tried to mimic this using curl I couldn't get it to work. Here is the curl request:
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/
I can't tell what Stash is expecting that isn't being provided by Curl in the second request. Any ideas?
Upvotes: 1
Views: 1815
Reputation: 1190
I got it working using wget. Here is the wget command:
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/
Upvotes: 1