HTTP Verb: PUT

Available statuses: 200 OK, 404 Not Found, 422 Unprocessable Entity

Object: Document

Location: n/a

Formats: XML, JSON

Update a document

Params

To update a document with a new file upload add the Content-Type multipart/form-data header to your request headers, the rest of params should be query string.

All params should be sent in the document namespace, e.g.:

document[file]=_file_data&document[name]=file name&...

In case no file upload is required data can be provided in three formats: XML, JSON and query string. To specify data type of XML or JSON add the Content-type: application/(json|xml) header to request headers, if you want to provide query string simply skip the Content-type header.

Examples

For example purposes we use a query string body, suppose the file is located in /home/max/myfile.

document[file]=@/home/max/myfile&document[name]=new name

Request XML, using cURL utility:

curl -i -H "Authorization: Bearer _token" -F "document[file]=@/home/max/myfile" -F "document[name]=new name" https://api.assembla.com/v1/spaces/_space_id/documents/_id.xml

Response

HTTP/1.1 200 OK
Server: nginx/0.8.55
Date: Wed, 20 Jun 2012 12:13:01 GMT
Content-Type: application/xml; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Status: 200
...

Request JSON, using cURL utility:

curl -i -H "Authorization: Bearer _token" -F "document[file]=@/home/max/myfile" -F "document[name]=new name" https://api.assembla.com/v1/spaces/_space_id/documents/_id.xml

HTTP/1.1 200 OK
Server: nginx/0.8.55
Date: Wed, 20 Jun 2012 12:05:41 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Status: 200
...

{}

For update operations no response body is available, to get the data of updated resource send a GET request to the same URL, i.e.:

curl -i -H "Authorization: Bearer _token" https://api.assembla.com/v1/spaces/_space_id/documents/_id.(xml|json)

Note: Extract from cURL documentation about -F flag

(HTTP) This lets curl emulate a filled-in form in which a user has pressed the submit button. This causes curl to POST data using the Content-Type multipart/form-data according to RFC 2388. This enables uploading of binary files etc. To force the ‘content’ part to be a file, prefix the file name with an @ sign. To just get the content part from a file, prefix the file name with the symbol <. The difference between @ and < is then that @ makes a file get attached in the post as a file upload, while the < makes a text field and just get the contents for that text field from a file.