プロジェクト

全般

プロフィール

Vote #79980

未完了

Rest API - create issue with custom fields

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Needs feedback
優先度:
通常
担当者:
-
カテゴリ:
REST API_32
対象バージョン:
-
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
32
version_id:
0
issue_org_id:
31186
author_id:
395377
assigned_to_id:
0
comments:
3
status_id:
10
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
148
ステータス-->[Needs feedback]

説明

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


journals

Did you solved it?

if your response is yes, how solved it?
--------------------------------------------------------------------------------
I use "custom_field_values" instead of "custom_fields"

Like this

<pre>
{
"issue":{
"project_id":"sandbox",
"subject":"Create test issue via api",
"tracker_id":"9",
"custom_field_values":[
{
"3":"VALUE"
}
]
}
}
</pre>

where key is ID of custom value.

--------------------------------------------------------------------------------
I'm not in the position to test anything at the moment, but please read [[Rest_api#Working-with-custom-fields|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).
--------------------------------------------------------------------------------

Admin Redmine さんが約4年前に更新

  • カテゴリREST API_32 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0