Web API Docs Add document

Navigate

Add a photo or video to a contribution.

Currently the following file formats are supported:

  • Images: .png, .jpg, .jpeg, .gif
  • Videos: .mov, .mpeg4, .avi, .wmv, .flv, .3gpp, .3gpp2, .webm
  • Audio: .wave, .wav, .mp3, .3gpp, .3gpp2

Request

POST /api/projects/:project_id/contributions/:contribution_id/media/

URL parameters

Parameter Type Description
project_id Integer Unique identifier for the project.
contribution_id Integer Unique identifier for the contribution.

Request headers

Header Required value
Content-Type multipart/form-data

POST body example

---XXX---
Content-Disposition: form-data; name="name"

Photo of the playground
---XXX---
Content-Disposition: form-data; name="description"

It clearly shows that the swing is broken
---XXX---
Content-Disposition: form-data; name="file"; filename="file.png"
Content-Type: image/png

---XXX---

Response

The response contains a document attached to the contribution.

{
    "id": 66,
    "name": "Photo of the playground",
    "description": "It clearly shows that the swing is broken",
    "isowner": true,
    "url": "/media/user-uploads/img-2165.jpg",
    "thumbnail_url": "/media/user-uploads/img-2165.jpg.300x300_q85_crop.png",
    "file_type": "ImageFile",
    "creator": {
        "id": 422,
        "display_name": "Peter Schmeichel"
    },
    "created_at": "2014-06-05T11:31:02.613Z"
}

Response codes

Code Reason
201 The document has been created successfully.
404 The project or contribution or document was not found. For security reasons we do not leak information about private projects, hence we don’t confirm existence private projects to unauthorised users.