Project

General

Profile

Actions

Defect #31186

open

Rest API - create issue with custom fields

Added by Josef Štěpánek almost 5 years ago. Updated about 4 years ago.

Status:
Needs feedback
Priority:
Normal
Assignee:
-
Category:
REST API
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Invalid
Affected version:

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

Actions

Also available in: Atom PDF