Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

REST API Create issue error parsing JSON

Jay
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 25, 2022

Getting this error "{"errorMessages":["There was an error parsing JSON. Check that your request body is valid."]} "

curl: (6) Could not resolve host: at
curl: (3) nested brace in URL position 397:

The Json is valid and im not sure why this bash curl coming out as error.

 

#!/usr/bin/bash
A="Storage warning at server"
B="2022-03-30"
C="Usage over 30% /home/rep (50%) on server as on Fri 25 Mar 2022 01:45:37 PM UTC"
curl --request POST --url 'https://rep.atlassian.net/rest/api/3/issue' --user 'jey@rep.com:'$APITOKEN'' --header 'Accept: application/json' --header 'Content-Type: application/json' \
--data '{
"fields":
{
"summary": "'$A'",
"duedate": "'$B'",
"reporter": {
"id": "12344534534534"
},
"issuetype": {
"id": "3"
},
"project": {
"key": "DEV",
"id": "12201",
"name": "DevOps"
},
"description": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{
"text": "'$C'",
"type": "text"
},
{
"type": "inlineCard",
"attrs": {
"url": "'$CI_PROJECT_URL'"
}
}
]
}
]
}
}
}'

2 answers

0 votes
Swarom Muley
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 12, 2023

I just fixed it by converting Python dictionary object to JSON 

json.dumps(your_json_data)
0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 25, 2022

Hi Jay -- Welcome to the Atlassian Community!

It appears you are passing more attributes than are needed to create the issue, such as the field type information.  Perhaps try something simpler to see how that helps.  And here is the a documentation page that might help also: https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/

{ 
"fields":
{
"summary": "'$A'",
"duedate": "'$B'",
"reporter": {
"id": "12344534534534"
},
"issuetype": {
"id": "3"
},
"project": {
"id": "12201"
},
"description": "'$C'"
}
}

Also please note you will need a valid account ID value to set the reporter field.

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events