Defect #8698
closedIssues REST-API not using valid XML anymore for XML node <custom_field_values/>
0%
Description
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. http://www.example.com/issues/18.xml ) 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>my.collegue@example.com</value></custom_field></custom_fields></issue>' | curl --insecure -X PUT -H 'Content-type: text/xml' -H 'Accept: text/xml' -d @- https://www.example.com/issues/18.xml?format=xml\&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>my.collegue@example.com</2></custom_field_values></issue>' | curl --insecure -X PUT -H 'Content-type: text/xml' -H 'Accept: text/xml' -d @- https://www.example.com/issues/18.xml?format=xml\&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
Updated by Etienne Massip over 13 years ago
- Target version set to Candidate for next minor release
Updated by Jean-Philippe Lang over 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" ?> <issue> <subject>API custom fields</subject> <custom_fields type="array"> <custom_field> <id>2</id> <value>Fixed</value> </custom_field> <custom_field> <id>1</id> <value>0.8.2</value> </custom_field> </custom_fields> </issue>
Updated by Etienne Massip over 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 !
Updated by Michael Pfannkuchen over 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