Defect #31186
openRest API - create issue with custom fields
0%
Description
Hi,
I have encountered a problem that when creating a new issue via REST api, it is not possible to give "custom field" as the desired parameter.
{ "issue":{ "project_id":"sandbox", "subject":"Create test issue via api", "tracker_id":"9", "custom_fields":[ { "value":"1234453", "id":3 } ] } }
I have defined custom field named "RFID" with id "3" and checked as compulsory
Client response:
"Client error: `POST https://xxx.eu/redmine/issues.json` resulted in a `422 Unprocessable Entity` response: {"errors":["RFID cannot be empty"]}"
Redmine log:
Started POST "/redmine/issues.json" for 192.168.62.1 at 2019-04-10 15:01:53 +0200 Processing by IssuesController#create as JSON Parameters: {"issue"=>{"project_id"=>"sandbox", "subject"=>"Create test issue via api", "tracker_id"=>"9", "custom_fields"=>{"0"=>{"value"=>"1234453", "id"=>"3"}}}} Current user: pserver (id=46) Rendering common/error_messages.api.rsb Rendered common/error_messages.api.rsb (0.3ms) Completed 422 Unprocessable Entity in 78ms (Views: 0.9ms | ActiveRecord: 15.4ms)
When I uncheck custom field as compulsory, request end successfully, but custom field RFID is not set.
{ "issue":{ "id":832, "project":{ "id":68, "name":"sandbox" }, "tracker":{ "id":9, "name":"Životopis ABA-ELE" }, "status":{ "id":1, "name":"Nový" }, "priority":{ "id":4, "name":"Normální" }, "author":{ "id":46, "name":"User user" }, "subject":"Create test issue via api", "description":null, "start_date":null, "due_date":null, "done_ratio":0, "is_private":false, "estimated_hours":null, "total_estimated_hours":null, "custom_fields":[ { "id":4, "name":"Charakteristika", "value":"" }, { "id":2, "name":"Výrobní štítek", "value":"" }, { "id":3, "name":"RFID", "value":"" } ], "created_on":"2019-04-10T13:12:31Z", "updated_on":"2019-04-10T13:12:31Z", "closed_on":null } }
I try add to custom field next value with key name, but result was same.
Do you have any idea whats wrong?
Thanks
Updated by Jose M Muñoz about 5 years ago
Did you solved it?
if your response is yes, how solved it?
Updated by Josef Štěpánek about 5 years ago
I use "custom_field_values" instead of "custom_fields"
Like this
{ "issue":{ "project_id":"sandbox", "subject":"Create test issue via api", "tracker_id":"9", "custom_field_values":[ { "3":"VALUE" } ] } }
where key is ID of custom value.
Updated by Mischa The Evil about 5 years ago
- Status changed from New to Needs feedback
- Resolution set to Invalid
I'm not in the position to test anything at the moment, but please read Rest_api#Working-with-custom-fields carefully and/or take a good look at the available test-coverage.
Note: some plugins seem to affect this functionality too (based on earlier postings), so check those too (or at least provide some info about which you are using, if any).