Rest api with curl » History » Revision 3
« Previous |
Revision 3/10
(diff)
| Next »
Jean-Philippe Lang, 2011-07-03 19:55
XML example with custom fields
Using the REST API with cURL¶
curl is a command-line tool for transferring data using various protocols. It can be used to interact with the Redmine REST API.
Using JSON¶
Here is a simple example of a command that can be used to update an issue:
curl -v -H "Content-Type: application/json" -X PUT --data "@388.json" -u login:password http://redmine/issues/388.json
The file that contains the data sent to Redmine (388.json in the example above) would look like this:
{
"issue": {
"subject": "subject123",
"notes": "Changing the subject"
}
}
Note: it's required to set the Content-Type header according to the format of the data you are sending. It must be set to one the following values:
application/jsonapplication/xml
Using XML¶
Here is a simple example of a command that can be used to create an issue with custom fields:
curl -v -H "Content-Type: application/xml" -X POST --data "@issue.xml" -u login:password http://redmine/issues.xml
Where issue.xml content is:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<issue>
<subject>API custom fields</subject>
<project_id>1</project_id>
<tracker_id>2</tracker_id>
<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 Jean-Philippe Lang over 14 years ago · 3 revisions