Hello!
I'm using the Jira API v2 to create an issue. I'm facing a trouble when I send a string with special caracteres on description filed.
Here the example that is working for me when I send a POST method to rest/api/2/issue:
var dataToCreateAnIssue = "{\"fields\":{\"project\":{\"key\":\"" + key + "\"},\"summary\":\"" + title + "\",\"description\":\"" + descp+ "\",\"issuetype\":{\"name\":\"Bug\"}}}";
But when I have special caracteres like ">" or "<" in my string dataToCreateAnIssue, I got the error 'The remote server returned an error: (400) Bad Request.'
I need to automate it, and my string will always have various special caracteres.
How can I resolve this? Any suggestion?
Hello @[deleted] ,
The description field needs some additional formatting to preserve the input variables as text rather than command inputs for the API call, and the following stripped-down example should do the trick to pass in the "<" and ">" characters as a basic example for the minimum inputs needed for a create issue POST:
curl --request POST \
--url 'https://your-domain.atlassian.net/rest/api/3/issue' \
--user 'email@example.com:<api_token>' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \ --data '{
"update": {},
"fields": {
"summary": "TEST API CREATE ISSUE",
"issuetype": {
"id": "10001"
},
"project": {
"id": "10000"
},
"description": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{
"text": "TEST API description with special characters < and >",
"type": "text"
}
]
}
]
}
}
}'
Additional details on the field formating check out the example section under the Create issue API documentation
Regards,
Earl
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.