Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Creating an issue using JIRA API endpoint .../rest/api/2/issue but description shows multiline HTML

Hello:

Using the following Jira API  endpoint to create an issue, sending the data in JSON (as per the documentation), I've tried several ways of getting multiline content for the description field:

url = "https://jira.mydomain.com/rest/api/2/issue"

payload
{
"fields": {
"project":
{
"key": "VPMG"
},
"summary": "Vulnerability detected by Qualys Scan at Finding.name ",
"description": "Vulnerability FindingDetails.id, group FindingDetails.group was detected at Finding.url ",
"issuetype": {
"name": "Bug"
}
}
}

So the description field (  that will contain much more information than above) will appear all in one line. This is a JSON, and what I want is to know if there is any way I can indicate JIRA that treat the description field as HTML, or all the fields as HTML so if I scape new line like \\n de description could appear in multiple lines.

1 answer

0 votes
Hana Kučerová Community Leader Jan 25, 2020

Hi @David Gutierrez ,

welcome to the Atlassian community!

It is possible to use HTML - the solution is described in this article.

But I would strongly recommend you to use Wiki markup formatting instead, mainly because of the security reasons.

I followed the Wiki markup formatting in my POST request to the JIRA API endpoint specified above to create an issue with no success

Here is my post request

def api_jira_create_ticket(payload=None):
url = "https://" + jira_base_url + "/rest/api/2/issue"
headers = {
'Content-Type': "application/json",
}
auth = requests.auth.HTTPBasicAuth(j_username, j_password)
response = requests.request("POST",
url,
data=payload,
auth=auth,
headers=headers)

Now this is my payload

description = f'---\
h2.Vulnerability 37 {f_details.id}, group {f_details.group} was detected at {f.url}/\\ \
\
---\
h3.REQUEST RESPONSE DETAILS\\ \
---\
---\
Authentication needed:{f_details.auth}\\ \
---\
Request method: {f_details.request_method}\\\
---\
Request link: {f_details.request_link}\\\
---\
Request header: {f_details.request_headers}/\\ \
. ---\
Payload: {f_details.payload}\\ \
Response: {f_details.response}\\ \
---\
h3.REMEDIATION\
---\
---\
OWASP_URL: {f_details.owasp_url}\\ \
OWASP RECOMENDATION: {f_details.owasp}\\ \
WASC_URL : {f_details.wasc_url}\\ \
WASC : {f_details.wasc}'

 Of course, it will be JSON.dumps() before sent.Note how I tried multiple combinations of markup as per the Wiki to no avail.

 

For example, it is supposed that the first line '---\ creates a horizontal ruler ( The \ is an indication for python of concatenation of multiline strings. Meanwhile 

h2.Vulnerability 37 {f_details.id}, group {f_details.group} was detected at {f.url}/\\ \

Should have created an h2 HTML text  followed by a newline (the fist \ is escaping )

 

If that was incorrect h3 should had been the correct case instead 

That did not work

What it worked for me was to use double \n\n as under

 

description = f'\n\n \
h2.Vulnerability 37 {f_details.id}, group {f_details.group} was detected at {f.url}\n\n \
\n\n \
h3.REQUEST RESPONSE DETAILS\n\n \
\n\n \
Authentication needed:{f_details.auth}\n\n \
Request method: {f_details.request_method}\n\n \
Request link: {f_details.request_link}\n\n\

 

So, in this case, all worked . Hope it helps 

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you