Project

General

Profile

Actions

Defect #11112

closed

REST API - custom fields in POST/PUT ignored for time_entries

Added by Ruediger Schobbert over 12 years ago. Updated over 12 years ago.

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

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

About your application's environment
Ruby version              1.9.3 (x86_64-linux)
RubyGems version          1.8.22
Rack version              1.1.3
Rails version             2.3.14
Active Record version     2.3.14
Active Resource version   2.3.14
Action Mailer version     2.3.14
Active Support version    2.3.14
Database adapter          mysql2
Database schema version   20120301153455

About your Redmine plugins
Environmnet CSS   0.1
Additional Information:
  • your database manager version: MySQL 5.1.61
  • your Redmine version: 1.4.1

Problem:
When using the REST API to create or modify time_entries, custom_fields are ignored if using XML format. When I use JSON, it succeeds (but only if using some different structure than the one described on the WIKI page http://www.redmine.org/projects/redmine/wiki/Rest_api )

I tried all of the following XML structures:
  • The one described on the WIKI page:
    <time_entry>
      <comments>changed via XML PUT - 1</comments>
      <custom_fields type="array">
        <custom_field id="4">
          <value>1131</value>
        </custom_field>
      </custom_fields>
    </time_entry>
    
  • But also all of the following (the last one is no valid XML but I tried it anyway)
    <time_entry>
      <comments>changed via XML PUT - 2</comments>
      <custom_fields type="array">
        <custom_field id="4">1132</custom_field>
      </custom_fields>
    </time_entry>
    
    <time_entry>
      <comments>changed via XML PUT - 3</comments>
      <custom_field_values>
        <custom_field id="4">1133</custom_field>
      </custom_field_values>
    </time_entry>
    
    <time_entry>
      <comments>changed via XML PUT - 4</comments>
      <custom_field_values>
        <4>1134</4>
      </custom_field_values>
    </time_entry>
    

If I use JSON it succeeds with the following format:

{"time_entry":
  {
    "comments":"changed via JSON PUT - 2",
    "custom_field_values":
      {
        "4":"13:02" 
      }
  }
}

  • If using the suggested format from the WIKI page, it does not work:
    {"time_entry":
      {
        "comments":"changed via JSON PUT - 1",
        "custom_fields":
          [
            {"value":"13:01","id":4}
          ]
      }
    }
    

Very interesting is, that XML POST/PUT with the documented format (WIKI page) works for issues!
So this succeeds:

<issue>
  <description>changed via XML PUT</description>
  <custom_fields type="array">
    <custom_field id="1">
      <value>0</value>
    </custom_field>
  </custom_fields>
</issue>

Actions #1

Updated by Jean-Philippe Lang over 12 years ago

  • Subject changed from REST API - custom fields in POST/PUT ignored for time_entries if using XML, only JSON is successful to REST API - custom fields in POST/PUT ignored for time_entries
  • Status changed from New to Confirmed
Actions #2

Updated by Jean-Philippe Lang over 12 years ago

  • Target version set to 2.0.3
Actions #3

Updated by Jean-Philippe Lang over 12 years ago

  • Status changed from Confirmed to Resolved
  • Assignee set to Jean-Philippe Lang
  • Resolution set to Fixed

Fixed in r9783.

Actions #4

Updated by Jean-Philippe Lang over 12 years ago

  • Status changed from Resolved to Closed

Merged in 1.4-stable and 2.0-stable.

Actions

Also available in: Atom PDF