Jump to >

Draft File Attachment List Resource

Added in 1.6

Provides information on new file attachments being added to a draft of a review request.

These are files that will be shown once the pending review request draft is published.

Details

Name draft_file_attachments
URI /api/review-requests/{review_request_id}/draft/file-attachments/
Token Policy ID draft_file_attachment
HTTP Methods
  • GET - Returns a list of draft files.
  • POST - Creates a new file from a file attachment.
Parent Resource Review Request Draft Resource
Child Resources
Anonymous Access No

HTTP GET

Returns a list of draft files.

Each file attachment in this list is an uploaded file attachment that will be shown in the final review request. These may include newly file attachments or files that were already part of the existing review request. In the latter case, existing files are shown so that their captions can be added.

Request Parameters

counts-onlyBoolean If specified, a single count field is returned with the number of results, instead of the results themselves.
max-resultsInteger The maximum number of results to return in this list. By default, this is 25. There is a hard limit of 200; if you need more than 200 results, you will need to make more than one request, using the “next” pagination link.
startInteger The 0-based index of the first result in the list. The start index is usually the previous start index plus the number of previous results. By default, this is 0.

Errors

100 - Does Not ExistHTTP 404 - Not Found Object does not exist
101 - Permission DeniedHTTP 403 - Forbidden You don’t have permission for this
103 - Not Logged InHTTP 401 - Unauthorized You are not logged in
105 - Invalid Form DataHTTP 400 - Bad Request One or more fields had errors
112 - OAuth2 Missing Scope ErrorHTTP 403 - Forbidden Your OAuth2 token lacks the necessary scopes for this request.
113 - OAuth2 Access Denied ErrorHTTP 403 - Forbidden OAuth2 token access for this resource is prohibited.

HTTP POST

Creates a new file from a file attachment.

This accepts any file type and associates it with a draft of a review request.

It is expected that the client will send the data as part of a multipart/form-data mimetype. The file’s name and content should be stored in the path field. A typical request may look like:

-- SoMe BoUnDaRy
Content-Disposition: form-data; name=path; filename="foo.zip"

<Content here>
-- SoMe BoUnDaRy --

Request Parameters

pathUploaded File Required

The file to upload.

attachment_historyInteger

ID of the corresponding FileAttachmentHistory.

Added in 2.5

captionString The optional caption describing the file.

Errors

100 - Does Not ExistHTTP 404 - Not Found Object does not exist
101 - Permission DeniedHTTP 403 - Forbidden You don’t have permission for this
103 - Not Logged InHTTP 401 - Unauthorized You are not logged in
105 - Invalid Form DataHTTP 400 - Bad Request One or more fields had errors
112 - OAuth2 Missing Scope ErrorHTTP 403 - Forbidden Your OAuth2 token lacks the necessary scopes for this request.
113 - OAuth2 Access Denied ErrorHTTP 403 - Forbidden OAuth2 token access for this resource is prohibited.

Examples

application/vnd.reviewboard.org.draft-file-attachments+json

$ curl http://reviews.example.com/api/review-requests/8/draft/file-attachments/ -H "Accept: application/json"
Vary: Accept, Cookie
Item-Content-Type: application/vnd.reviewboard.org.draft-file-attachment+json
Content-Type: application/vnd.reviewboard.org.draft-file-attachments+json
X-Content-Type-Options: nosniff
{
  "draft_file_attachments": [
    {
      "absolute_url": "http://example.com/media/uploaded/images/2010/08/13/screenshot1.png", 
      "attachment_history_id": null, 
      "caption": "Example Attachment", 
      "filename": "screenshot1.png", 
      "icon_url": "/static/rb/images/mimetypes/text-x-generic.png", 
      "id": 1, 
      "links": {
        "delete": {
          "href": "http://reviews.example.com/api/review-requests/8/draft/file-attachments/1/", 
          "method": "DELETE"
        }, 
        "self": {
          "href": "http://reviews.example.com/api/review-requests/8/draft/file-attachments/1/", 
          "method": "GET"
        }, 
        "update": {
          "href": "http://reviews.example.com/api/review-requests/8/draft/file-attachments/1/", 
          "method": "PUT"
        }
      }, 
      "mimetype": "image/png", 
      "review_url": "", 
      "revision": 0, 
      "thumbnail": "<div class=\"file-thumbnail\"> <img src=\"/media/uploaded/images/2010/08/13/screenshot1_300.png\" srcset=\"/media/uploaded/images/2010/08/13/screenshot1_300.png 1x, /media/uploaded/images/2010/08/13/screenshot1_600.png 2x\" alt=\"Example Attachment\" width=\"300\" /></div>", 
      "url": "http://example.com/media/uploaded/images/2010/08/13/screenshot1.png"
    }
  ], 
  "links": {
    "create": {
      "href": "http://reviews.example.com/api/review-requests/8/draft/file-attachments/", 
      "method": "POST"
    }, 
    "self": {
      "href": "http://reviews.example.com/api/review-requests/8/draft/file-attachments/", 
      "method": "GET"
    }
  }, 
  "stat": "ok", 
  "total_results": 1
}