プロジェクト

全般

プロフィール

Vote #74836

完了

REST API: Integer custom field validation fails when using non-string values

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

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

0%

予定工数:
category_id:
32
version_id:
75
issue_org_id:
15929
author_id:
94010
assigned_to_id:
1
comments:
2
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

I have an issue custom field "My field" of integer type. This field doesn't have any additional validation rules for length and regexp.
When I try to update it's value for some issue, validation fails with message "My field is not a number".
I tried both variants for custom fields:

{"issue":{"custom_field_values":{"12":15}}}
{"issue":{"custom_fields":[{"id":12,"value":15}]}}

Result is the same.
Here is the part of production.log:

Started PUT "/issues/788.json" for 2a00:9700:0:10:1e6f:65ff:fe54:fb4a at Wed Jan 22 16:45:48 +0700 2014
Processing by IssuesController#update as JSON
 Parameters: {"issue"=>{"custom_field_values"=>{"12"=>15}}, "id"=>"788"}
 Current user: vitek (id=1)
 Rendered common/error_messages.api.rsb (0.7ms)
Completed 422 Unprocessable Entity in 273.8ms (Views: 1.9ms | ActiveRecord: 24.9ms)

journals

Just found the way to avoid the error. Integer parameter should be casted to string.
It works if submit this data:
<pre>
{"issue":{"custom_field_values":{"12":"15"}}}
</pre>
I really don't understand why Redmine wants numeric string for the number custom field instead of integer
--------------------------------------------------------------------------------
Fixed in r12704, thanks for pointing this out.
--------------------------------------------------------------------------------

Admin Redmine さんが3年以上前に更新

  • カテゴリREST API_32 にセット
  • 対象バージョン2.5.0_75 にセット

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

いいね!0
いいね!0