Project

General

Profile

Rest api with curl » History » Version 2

Jean-Philippe Lang, 2010-12-11 14:51
Note about content-type

1 1 Jean-Philippe Lang
h1. Using the REST API with cURL
2
3
"curl":http://curl.haxx.se/ is a command-line tool for transferring data using various protocols. It can be used to interact with the Redmine REST API.
4
5
Here is a simple example of a command that can be used to update an issue:
6
7
<pre>
8
curl -v -H "Content-Type:application/json" -X PUT --data "@388.json" -u login:password http://redmine/issues/388.json
9
</pre>
10
11
The file that contains the data sent to Redmine (388.json in the example above) would look like this:
12
13
<pre>
14
{
15
  "issue": {
16
    "subject": "subject123",
17
    "notes": "Changing the subject"
18
  }
19
}
20
</pre>
21 2 Jean-Philippe Lang
22
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:
23
* @application/json@
24
* @application/xml@