I am using Stash 3.11.1 and curl-7.33.0-win64
According to https://developer.atlassian.com/static/rest/stash/3.11.0/stash-scm-git-rest.html it's possible to tag remote repositories via ReST API.
So I tried. My cURL call looks as follows:
curl -u myuser:mypassword -H "Content-Type: application/json" -X POST -d '{"force":"true","message":"test-msg","name":"test-name","startPoint":"refs/heads/master","type":"ANNOTATED"}' http://stash.mycompany.int:7990/projects/SAMPLE/repos/sample/tags
What I retrieve is some HTML text which shows the navigation menu (projects, repositores, etc.). But there's also a headline "Oops, you've found a dead link". Is this ReST API still up to date? I think it was introduced with 3.8 and not public so it MIGHT have changed. Checking in Stash UI: There is no new tag :/
Any ideas? (Tell me if you need more information).
Community moderators have prevented the ability to post new answers.
Hi @Martin Schemel,
it looks like the URL you are specifying in your curl call is not correct.
The following command should work:
curl -u myuser:mypassword -H "Content-Type: application/json" -X POST -d '{"force":"true","message":"test-msg","name":"test-name","startPoint":"refs/heads/master","type":"ANNOTATED"}' http://stash.mycompany.int:7990/rest/git/1.0/projects/SAMPLE/repos/sample/tags
Note the "/rest/git/1.0/" in the url.
I hope that helps,
Felix
At first, thank you for that quick response, @Felix Haehnel!
Now I notice that this "/rest/git/1.0/" path is documented on the page I just posted. Sorry for that.
This seems to solve at least this concrete problem. So I corrected the URL. Now the URL seems to be correct but I get the following response:
{"errors":[{"context":null,"message":"Unexpected character (''' (code 39)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: org.apache.catalina.connector.CoyoteInputStream@740c2ac6; line: 1, column: 2]","exceptionName":"org.codehaus.jackson.JsonParseException"}]}
So it seems that my JSON format is corrupt.
It seems that on the one hand a context needs to be specified (how/what?) and on the other hand the message contains an invalid '
sign? I already tried to remove the -
sign from the message which did not help.
Any ideas again?
Seems to be a OS related problem. When I call
-d "{\"force\": \"true\",\"message\": \"A new release tag\",\"name\": \"release-tag2\",\"startPoint\": \"refs/heads/master\",\"type\": \"ANNOTATED\"}"
instead of
-d '{"force": "true","message": "A new release tag","name": "release-tag2","startPoint": "refs/heads/master","type": "ANNOTATED"}'
it works. So basically I have to escape the inner quotation marks.
I'm using Windows 7 64bit.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I just tried the command as I posted it in my answer on Stash 3.10.2 (Windows, using curl in Cygwin) - it worked for me. I would suggest you try saving the JSON to a file and referencing that in your curl command. For example: curl -u myuser:mypassword -H "Content-Type: application/json" -X POST -d @myfile.json http://stash.mycompany.int:7990/rest/git/1.0/projects/SAMPLE/repos/sample/tags
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yep with a file it works fine. You helped me a lot. Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Felix, How to store user input to json file?
I am trying to create bitbucket project using below curl command:
curl -X POST -H "Content-type: application/json" --basic --user $username:$password https://abc.com/bitbucket/rest/api/1.0/projects -d '{"key": '$projectname', "name": '$projectname', "description": '$projectname'}'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.