I am trying to create a Jira issue with a code snippet in the description.
I am new to the Atlassian REST API, so help would be much appreciated.
Also, a link to what kinds of formatting the description field can take for creating a Jira issue would be much appreciated.
After many trials and errors and trying to see what the Jira UI was sending to its backend, I tried something like this as the JSON body with a POST call to "/rest/api/3/issue/" to create an issue:
{
"fields": {
"summary": "Some Summary",
"description": {
"version": 1,
"type": "doc",
"content": [
{
"type": "codeBlock",
"attrs": {
"language": "javascript"
},
"content": [
{
"type": "text",
"text": "some code here with proper escapes"
}
]
}
]
},
"project": {
"key": "some_key"
},
"priority": {
"id": "some_priority"
},
"issuetype": {
"name": "some_issue_type"
}
}
}
I'm not sure what the best way to do this is, so I think there needs to be more documentation and examples. Maybe I am looking at the wrong places, but the documentation looks a little sparse.
https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-rest-api-3-issue-post
I would like to know what attributes I can mess around with for "description", but the "fields" attribute is just an object without any explanation of how to utilize the "description" attribute inside of it.
Hi, maybe to late but just in case see also https://developer.atlassian.com/cloud/jira/platform/apis/document/structure/
as the description is a "paragraph" top-node - see also https://developer.atlassian.com/cloud/jira/platform/apis/document/nodes/paragraph/
but yes overall it is a hard to understand in my mind
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You need to send a POST call to:
https://your_jira_url/rest/api/2/issue/{issueKey}/comment
add header:
"Content-Type", "application/json"
your body data should be like:
{
"body": "{code:java}// code placeholder{code}"
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I want to create an issue and insert a description. The code block needs to be in the description. I saw something here:
https://confluence.atlassian.com/doc/code-block-macro-139390.html
I have tried inserting the code macro inside of the "description" text and it worked.
{
"fields": {
"summary": "Some Summary",
"description": "{code:title=Detailed Results|theme=FadeToGrey|linenumbers=true|language=javascript|firstline=0001|collapse=true}some code with proper escapes{code}",
"project": {
"key": "some_key"
},
"priority": {
"id": "some_priority"
},
"issuetype": {
"name": "some_issue_type"
}
}
}
My underlying question is where I can find documentation for this. What attributes and fields can I place inside the "description" attribute?
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.