Project

General

Profile

Actions

Feature #11952

open

Multiple entries insert in a custom fields list with the REST API

Added by Pierre Labrie about 12 years ago. Updated about 12 years ago.

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

0%

Estimated time:
Resolution:

Description

I am working on a conversion from an old system to Redmine and I use the REST API with the .NET client API. I need to set a multiple list custom field with one or more selected values. My conversion is working well for a single value but if there is 2 or more values, the code won't let me insert more than one because the array is converted to an hash in acts_as_customizable and duplicate values of the key is eliminated by design.

My XML POST

<issue>
<subject>AN:1 premier test pour une nouvelle demande</subject>
<description>*Problématique* </description>
<project_id>2</project_id>
<status_id>3</status_id>
<category_id>47</category_id>
<tracker_id>3</tracker_id>
<assigned_to_id>27</assigned_to_id>
<fixed_version_id>15</fixed_version_id>
<parent_issue_id>0</parent_issue_id>
<start_date>2009-08-27</start_date>
 <custom_fields type=\"array\">
  <custom_field id=\"11\">
   <value>Guides électroniques</value>
  </custom_field>
  <custom_field id=\"11\">
   <value>Portails régionaux</value>
  </custom_field>
 </custom_fields>
</issue>

And the resulting parameter array (partial)

"custom_fields"=>[{"value"=>"Guides électroniques", "id"=>"11"}, {"value"=>"Portails régionaux", "id"=>"11"}],

But if I submit a different key/value it works well by affecting two differents custom fields

"custom_fields"=>[{"value"=>"Guides électroniques", "id"=>"10"}, {"value"=>"Portails régionaux", "id"=>"11"}],

If I manually insert the values in the database, it works also.

The solution would be to convert the parameter array the same way the GUI does for multiple custom fields list.

Bitnami Redmine Stack
Environment:
  Redmine version                          2.1.0.stable
  Ruby version                             1.8.7 (i386-mingw32)
  Rails version                            3.2.8
  Environment                              production
  Database adapter                         Mysql2
Actions #1

Updated by Pierre Labrie about 12 years ago

  • Status changed from New to Resolved

I have been able to insert correctly multiple entries in a custom field list with a modified XML POST. I had to modifify the Redmine .NET API to obtain the right XML structure.

<issue>
<subject>AN:1 premier test pour une nouvelle demande</subject>
<description>*Problématique*des électroniques, Portails régionaux\r\n\r\n*Demandeur:* </description>
<project_id>2</project_id>
<status_id>3</status_id>
<category_id>47</category_id>
<tracker_id>3</tracker_id>
<assigned_to_id>27</assigned_to_id>
<fixed_version_id>15</fixed_version_id>
<parent_issue_id>0</parent_issue_id>
<start_date>2009-08-27</start_date>
  <custom_fields type="array">
    <custom_field id="11">
      <value type="array">
        <value>Guides électroniques</value>
        <value>Portails régionaux</value>
    </value>
  </custom_field>
</custom_fields>
</issue>
Actions

Also available in: Atom PDF