Can we update custom field dynamically by using REST API

Sreenivas Narala May 31, 2022

Hi Folks,

I am trying to update selectlist custom field dynamically by using REST API and getting input data from REST API and passing that data by using variable but while running the curl getting below error and we are using v2 REST API method.

command : curl -D- -u "Test@abc.com":"jiraadmin123" -X POST --data {"fields": {"customfield_16600": {"value":"$name"}, {"id":"null"}}} -H "Content-Type: application/json" https://abc.test.com/rest/api/2/issue/

Error : {"errorMessages":["Unexpected character ('f' (code 102)): was expecting double-quote to start field name\n at [Source: org.apache.catalina.connector.CoyoteInputStream@1c271e0a; line: 1, column: 3]"]}

Could you please check and let me know if any solution for this task.

2 answers

1 vote
Prince Nyeche
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.
June 1, 2022

If you're using this snippet from the command line, isn't your data argument value suppose to be wrapped in single quotes? 

--data '{"fields":
}'

Sreenivas Narala June 6, 2022

Thank you, tried without quotes but getting below error and not able to process the data without quotes.

--data {"fields": {"project":{"id": "18500"}, "customfield_16600": {"id":"19302", "value": "$name1"}}}

Error :-

{"errorMessages":["Unexpected character ('f' (code 102)): was expecting double-quote to start field name\n at [Source: org.apache.catalina.connector.CoyoteInputStream@57991445; line: 1, column: 3]"]}

Please let me know if i missed any required parameter for data.

Prince Nyeche
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.
June 6, 2022
--data '{"fields": {"project":{"id": "18500"}, "customfield_16600": {"id":"19302", "value": "$name1"}}}'

Do you see the single quote before the curly bracket, you're suppose to have that. 

0 votes
Djiga Sene June 2, 2022

Generaly i have an error when i'm using the value of the option.

You can use the option Id (for select list, radio button field).

You can check it in jira database or directly by editing the option on the url, you will have it in the selectedValue parameter.

Usually it starts with 10000.

Sreenivas Narala June 6, 2022

Thank you, yes am trying with option id but not able to update field values able to create issues and update summary,

Here observed it's allowing to update existing values only if i tried with new entry getting unexpected value and not able to find out the option id.

--data {"fields": {"project":{"id": "18500"}, "customfield_16600": {"id":"19302", "value": "$name1"}}} 

FYI..trying to publish dynamically with $name1.

Could you please check and let me know if any solution for this task.

Suggest an answer

Log in or Sign up to answer