Hello,
As the title says, I'm trying to use the Stash REST API to create a new tag for a Git repository. There are a couple Atlassian pages that cover this topic, but I've run into some issues trying to follow them.
I've tried to mirror the examples as closely as possible (edited to reflect progress made since original posting):
curl -u fred:fred http://localhost:7990/rest/api/1.0/projects/WORK/repos/my-repo/commits/?until=master
curl -u roygarr:password https://stash.metro.ad.selinc.com/rest/api/1.0/projects/WINT/repos/tagging_test_1/commits/????until=master
This seems to work out pretty well. I get an easy-to-parse JSON response from the server.
curl -v -H "Content-Type: application/json" -H "Accept: application/json" -u 'user:pass' -X POST --data-binary @data http://localhost:7990/rest/api/1.0/projects/LULU/repos/lulu/pull-requests
curl -u roygarr:password -H "Content-Type: application/json" -H "Accept: application/json" -X POST --data-binary @tag.json https://stash.metro.ad.selinc.com/rest/git/1.0/projects/WINT/repos/tagging_test_1/tags
TAG.JSON { "force": "true", "message": "A new release tag", "name": "release-tag", "startPoint": "refs/heads/master", "type": "ANNOTATED" }
This one gave me a 400 error. Unlike other attempts, where I received a JSON that contained error information, this attempt gave me a JSON that seemed to contain my tag information.
<HEAD><TITLE>Invalid HTTP Request</TITLE></HEAD> <BODY BGCOLOR="white" FGCOLOR="black"><H1>Invalid HTTP Request</H1><HR> <FONT FACE="Helvetica,Arial"><B> Description: Bad request syntax</B></FONT> <HR> <!-- default "Invalid HTTP Request" response (400) --> </BODY> {"id":"refs/tags/release-tag","displayId":"release-tag","latestChangeset":"ddd06488e286cd8b49b62e6bed6b804e024cb6cd","latestCommit":"ddd06488e286cd8b49b62e6bed6b804e024cb6cd","hash":"f1a90f155c95526fbcd23c85bfed268850132914"}
The tag appears to not have taken effect, matching what the response offers.
Any help you can offer would be appreciated,
- Roy
https://developer.atlassian.com/stash/docs/latest/how-tos/command-line-rest.html
https://developer.atlassian.com/static/rest/stash/3.11.3/stash-scm-git-rest.html
https://jira.atlassian.com/browse/BSERV-4276
Community moderators have prevented the ability to post new answers.
It seems the order of things and the placement of apostrophes in the curl command is important. This appears to have worked:
curl -H "Content-Type: application/json" -H "Accept: application/json" -u 'roygarr:password' -X POST --data-binary @tag.json https://stash.metro.ad.selinc.com/rest/git/1.0/projects/WINT/repos/tagging_test_1/tags
The error from earlier is still an oddity, but doesn't come up in this scenario.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.