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.
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
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.