Rest api with curl » History » Version 1

Jean-Philippe Lang, 2010-12-11 14:48

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