Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,295,955
Community Members
 
Community Events
165
Community Groups

Can we update custom field dynamically by using REST API

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

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":
}'

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.

--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. 

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.

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
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you