Defect #8698


Issues REST-API not using valid XML anymore for XML node <custom_field_values/>

Added by Michael Pfannkuchen almost 13 years ago. Updated almost 13 years ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:
Affected version:


I'm using REST API for importing issues into Redmine.
Used Framework is PHP/ActiveResource.php - this worked fine with Redmine 1.1.2.
With Redmine 1.2.0 the API changed , so that non-valid XML is necessary to create/update issues now. As far as I see only the POST and PUT requests changed, the GET requests (eg. ) still working the way before.

This REST-API Update sample worked with Redmine 1.1.2 (written as curl code):
echo '<?xml version="1.0" encoding="ISO-8859-1" ?><issue><project_id>9</project_id><custom_fields><custom_field><id>2</id><name>reporter</name><value></value></custom_field></custom_fields></issue>' | curl --insecure -X PUT -H 'Content-type: text/xml' -H 'Accept: text/xml' -d @-\&key=12356454654

To get the same Update action done you have now (with Redmine 1.2.0) to write :
echo '<?xml version="1.0" encoding="ISO-8859-1" ?><issue><project_id>9</project_id><custom_field_values><2></2></custom_field_values></issue>' | curl --insecure -X PUT -H 'Content-type: text/xml' -H 'Accept: text/xml' -d @-\&key=12356454654
The second syntax is not XML-valid and not possible to work out with PHP/ActiveResource.php

Ruby version 1.8.7 (x86_64-linux)
RubyGems version 1.6.2
Rack version 1.1.2
Rails version 2.3.11
Active Record version 2.3.11
Active Resource version 2.3.11
Action Mailer version 2.3.11
Active Support version 2.3.11
Edge Rails revision unknown
Application root /home/srv/www/redmine-1.2.0
Environment production
Database adapter mysql
Database schema version 20110511000000

Actions #1

Updated by Etienne Massip almost 13 years ago

  • Target version set to Candidate for next minor release
Actions #2

Updated by Jean-Philippe Lang almost 13 years ago

  • Status changed from New to Closed
  • Target version deleted (Candidate for next minor release)
  • Resolution set to Invalid

I think that the attribute type="array" is missing on your custom_fields tags.

Here is a working example for creating an issue with custom fields:

curl -v -H "Content-Type: application/xml" -X POST --data "@issue.xml" -H "X-Redmine-API-Key: xxxx" http://localhost:3000/projects/myproject/issues.xml

where issue.xml content is:

<?xml version="1.0" encoding="ISO-8859-1" ?>
  <subject>API custom fields</subject>
  <custom_fields type="array">
Actions #3

Updated by Etienne Massip almost 13 years ago

This is not very intuitive, why would we have to specify something that seems implementation relevant in the request XML ?

Guess it's a RoR requirement, but erh !

Actions #4

Updated by Michael Pfannkuchen almost 13 years ago

Ah: I see. The forum message REST API json/xml syntax for updating/creating issues misleaded me completely. In this message the <$id-number>value</$id-number> syntax is described as the way to use the Issues REST Api by now.
Using the type="array" attribute I can use the ActiveResource.php framework again - many thanks for your help, Jean-Philippe.

Happy projects : Michael


Also available in: Atom PDF