Is my JSON incorrectly formatted?

R. Simpson February 18, 2021

I am POST'ing the following data to our server's v2 API using Python's request library.

{
"fields": {
"customfield_10300": "8lbs 3oz",
"customfield_10315": {
"value": "Mississippi",
"child": "Harrison"
},
"project": {
"key": "BOD"
},
"issuetype": {
"name": "Task"
}
}
}

 

I get an error:

{
"customfield_10315": "Can not instantiate value of type [simple type, class com.atlassian.jira.issue.fields.rest.json.bean.CustomFieldOptionJsonBean] from JSON String; no single-String constructor/factory method (through reference chain: com.atalassianl.jira.issue.fields.rest.json.beans.CustomFieldOptionJsonBean[\"child\"])"
}


Is my JSON incorrectly formatted?
Where could I have gone to figure this out on my own? I unsuccessfully tried searching the documentation. I also tried googling a solution, but the results all seemed to indicate those people were double-encoding their JSON strings by accident, which I don't think I am doing.

2 answers

0 votes
Thomas Deiler
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 4, 2021

Dear @R. Simpson ,

updating custom fields can be tricky. what type of custom is customfield_10315? What's your REST endpoint?

So long

Thomas

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.
February 18, 2021

Hi @R. Simpson  -- Welcome to the Atlassian Community!

I noted that your project field name is not enclosed in quotation marks.  Have you tried to add those?

Best regards,

Bill

R. Simpson February 18, 2021

Apologies:  that was a typo.

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.
February 18, 2021

Gotcha, and thanks. A few more ideas:

You may want to check out the REST API call to create issue, which uses the ID values rather than the names for such JSON access.  I cannot tell what transaction you are calling to know if that is relevant:

https://docs.atlassian.com/software/jira/docs/api/REST/1000.824.0/#api/2/issue-createIssue

Next, to confirm you are accessing the correct smart values/field names, you could make a call to the REST API with an example issue to check.  Here's an explanation of that:

https://support.atlassian.com/jira-software-cloud/docs/find-the-smart-value-for-a-field/

Suggest an answer

Log in or Sign up to answer