Hey there, I am creating issues using API, however, I cannot find URL for created issues in the response body.
How can I get the URL for a created issue using API?
Thanks!
Hi Zharkyn,
The Cloud Rest API documentation for issue creation shows that the issue key and URL are returned. Atlassian's example is below.
{ "<span>issues</span>": <span>[ { "id": "10000", "key": "TST-24", "self": "http://www.example.com/jira/rest/api/2/issue/10000" }, { "id": "10001", "key": "TST-25", "self": "http://www.example.com/jira/rest/api/2/issue/10001" } ]</span>, "<span>errors</span>": <span>[]</span>}
The id value is the issue ID, key value is the issue key, and the self value is the issue URL. Cheers!
Hi @Zharkyn Kassenov
in case it is still not working - could you probably post the response of your call here?It then might be easier to dig in deeper.
Regards,Daniel
Hi @Joshua Sneed Contegix , @Daniel Ebers ,
Thank you for your replies. What I was actually after is URL that can be opened in a browser to navigate to the created issue. I only see API URL of the issue in the response. Sorry for not being clear in the question.
Like Joshua showed there is the key as a response, this is the "dynamic" part of the URL, the rest is "static" like https://yourgreatsite.atlassian.net - the task would only be to concatenate your URL + the project key.
You mentioned you see only API URL in response key. I am unsure why - could you please show an anonymized output here?
Plug the key into Jira's standard issue URL to access it in the UI. E.g. http://www.example.com/browse/${key}. Cheers!
How about this
const issueUILink = issue.self.split('/rest/api')[0] + "/browse/" + issue.key;
@Joshua Sneed Contegix's approach is the best I could find.
// calculate a browser URL from the issueconst baseUrl = jiraIssue.self.replace(/\/rest\/api\/.*/,'')const browserUrl = baseUrl +"/browse/" + jiraIssue.key
Odd that the returned issue doesn't include a user/browser-friendly URL. The code above will break if the REST URL format ever changes drastically.
It looks like you're new here. Sign in or register to get started.