Defect #15929

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

Added by Victor Safronov over 4 years ago. Updated over 4 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:REST API
Target version:2.5.0
Resolution:Fixed Affected version:

Description

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)

Associated revisions

Revision 12704
Added by Jean-Philippe Lang over 4 years ago

REST API: Integer custom field validation fails when using non-string values (#15929).

History

#1 Updated by Victor Safronov over 4 years ago

Just found the way to avoid the error. Integer parameter should be casted to string.
It works if submit this data:

{"issue":{"custom_field_values":{"12":"15"}}}

I really don't understand why Redmine wants numeric string for the number custom field instead of integer

#2 Updated by Jean-Philippe Lang over 4 years ago

  • Subject changed from Integer custom field fails validation when updated using REST API to REST API: Integer custom field validation fails when using non-string values
  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang
  • Target version set to 2.5.0
  • Resolution set to Fixed

Fixed in r12704, thanks for pointing this out.

Also available in: Atom PDF