Forums

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

CURL API unable to parse JSON

Elsie Carroll
Contributor
July 20, 2026

We're trying to get the API for creating an issue working.  It didn't have any issues previously, but the same error is popping up in two different processes and we're not sure where the parsing problem is coming from.

This is the curl call we're using (slightly censored) 

curl --silent -D- -u "${USERNAME}" -X POST -d @- -H "Content-Type: application/json" -H 'Accept: application/json' https://INSERT_COMPANY_HERE.atlassian.net/rest/api/3/issue < /dev/stdin

We're using the dev/stdin because we want to use this across multiple projects and it's simpler to build a payload in another file than keep track of all the variables needed and insert them here.  This is the payload that brought this issue to our attention, claiming that it can't parse the json

 {
"fields": {
"project":
{
"key": "DS"
},
"summary": "FILLER TEXT ${file}",
"issuetype": {
"name": "FILLER TEXT"
},
"description": {
"content": [
{
"content": [
{
"text": "${file} in ${FILEPATH} FILLER TEXT ${validate}. Please investigate further.",
"type": "text"
}
],
"type": "paragraph"
}
],
"type": "doc",
"version": 1
},
"customfield_10202" : "9566",
}

None of the variables here can be removed, since we need them for troubleshooting purposes when the issue is created.  Adding single quotes around the payload make the variables literal, which is obviously an issue. 

2 answers

1 accepted

1 vote
Answer accepted
Aron Gombas _Midori_
Community Champion
July 20, 2026

Isn't the problem simply that one of the variables gets replaced by a string which contains a quotation character?

I mean, see for example this:

"summary": "FILLER TEXT ${file}",

If "${file}" is replaced with for example this:

"Hello!"

then the output becomes:

"summary": "FILLER TEXT "Hello!"",

which is obviously broken in JSON. 

In other words, the approach you are using will only work if your variable values don't contain quotation characters.

Elsie Carroll
Contributor
July 21, 2026

That is absolutely it - I thought it couldn't be because it worked in testing previously, but your comment made me realize that I never tested it once I added the validation text, which can sometimes contain a quote.  Gives me more problems to fix, but at least I know that it works!  Thanks so much!!!

Like Aron Gombas _Midori_ likes this
1 vote
Alexandre Pezzini
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 20, 2026

Based on the payload provided in the community post, there is a syntax error that is likely the root cause of the parsing failure.

The Findings

The JSON payload contains a trailing comma after the last field in the fields object. Standard JSON parsers (including the one used by the Jira API) will fail if there is a comma after the final element in an object or array.

The error in the payload:

"customfield_10202" : "9566",  <-- This comma is the problem
}
}

The Solution

To resolve this, you must remove the trailing comma. Additionally, since you are using shell variables (like ${file} and ${FILEPATH}) inside a file that is being piped to curl, you need to ensure that your shell is actually expanding those variables before they reach the API.

1. Corrected JSON Payload:

{
  "fields": {
    "project": {
      "key": "DS"
    },
    "summary": "FILLER TEXT ${file}",
    "issuetype": {
      "name": "Task" 
    },
    "description": {
      "version": 1,
      "type": "doc",
      "content": [
        {
          "type": "paragraph",
          "content": [
            {
              "type": "text",
              "text": "${file} in ${FILEPATH} FILLER TEXT ${validate}. Please investigate further."
            }
          ]
        }
      ]
    },
    "customfield_10202": "9566"
  }
}

2. Handling Variables in the Shell:
If you are storing this JSON in a file and using < /dev/stdin, the shell variables ${file} etc., will not be expanded automatically if they are just text in a file. You have two options:

  • Option A (Using envsubst): If you have the gettext package installed, you can expand the variables on the fly:

    envsubst < payload.json | curl --silent -D- -u "${USERNAME}:${API_TOKEN}" \
    -X POST -H "Content-Type: application/json" \
    --data-binary @- \
    https://your-domain.atlassian.net/rest/api/3/issue
  • Option B (Heredoc): Build the payload directly in your script to ensure variables are parsed:

    payload=$(cat <<EOF
    {
      "fields": {
        "project": {"key": "DS"},
        "summary": "FILLER TEXT ${file}",
        "issuetype": {"name": "Task"},
        "description": {
          "version": 1,
          "type": "doc",
          "content": [{"type": "paragraph", "content": [{"type": "text", "text": "${file} in ${FILEPATH}..."}]}]
        },
        "customfield_10202": "9566"
      }
    }
    EOF
    )
    echo "$payload" | curl ... --data-binary @-

Next Steps

  1. Remove the trailing comma after "customfield_10202" : "9566".

  2. Verify the Issue Type Name: Ensure that "FILLER TEXT" is replaced with a valid work item type name (e.g., "Task" or "Bug") that exists in the "DS" space.

  3. Check API Token: Ensure you are using an API Token rather than a password for the -u parameter in Jira Cloud.

Sources

Elsie Carroll
Contributor
July 20, 2026

I can confidently say the trailing comma isn't the issue - that's left over from some testing I was doing prior to posting this, and the issue type/API token should have been fine, but I will do some more testing to make sure and accept the answer if that turns out to have been the problem!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events