Project

General

Profile

Actions

Defect #15929

closed

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

Added by Victor Safronov about 10 years ago. Updated about 10 years ago.

Status:
Closed
Priority:
Normal
Category:
REST API
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
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)
Actions #1

Updated by Victor Safronov about 10 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

Actions #2

Updated by Jean-Philippe Lang about 10 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.

Actions

Also available in: Atom PDF