Content - attachments

Create attachment

Adds an attachment to a piece of content. This method only adds a new attachment. If you want to update an existing attachment, use Create or update attachments.

Note, you must set a X-Atlassian-Token: nocheck header on the request for this method, otherwise it will be blocked. This protects against XSRF attacks, which is necessary as this method accepts multipart/form-data.

The media type 'multipart/form-data' is defined in RFC 7578. Most client libraries have classes that make it easier to implement multipart posts, like the MultipartEntityBuilder Java class provided by Apache HTTP Components.

Note, according to RFC 7578, in the case where the form data is text, the charset parameter for the "text/plain" Content-Type may be used to indicate the character encoding used in that part. In the case of this API endpoint, the comment body parameter should be sent with type=text/plain and charset=utf-8 values. This will force the charset to be UTF-8.

Example: This curl command attaches a file ('example.txt') to a container (id='123') with a comment and minorEdits=true.

curl -D- \
  -u admin:admin \
  -X POST \
  -H 'X-Atlassian-Token: nocheck' \
  -F 'file=@"example.txt"' \
  -F 'minorEdit="true"' \
  -F 'comment="Example attachment comment"; type=text/plain; charset=utf-8' \
  https://myhost/wiki/rest/api/content/123/child/attachment

Permissions required: Permission to update the content.

post/wiki/rest/api/content/{id}/child/attachment

Request

  • Base URL
    https://your-domain.atlassian.net
  • URL
    https://your-domain.atlassian.net/wiki/rest/api/content/{id}/child/attachment
  • Auth
    • HTTP basic
    • or OAuth 2
      Authorization code: https://auth.atlassian.com/authorize
      Token URL: https://auth.atlassian.com/oauth/token scopes: write:confluence-file

Path parameters

idstring required

The ID of the content to add the attachment to.

Query parameters

status'current' | 'draft'

The status of the content that the attachment is being added to.

Request body multipart/form-data

filestring binary required

The relative location and name of the attachment to be added to the content.

commentstring binary

The comment for the attachment that is being added. If you specify a comment, then every file must have a comment and the comments must be in the same order as the files. Alternatively, don't specify any comments.

minorEditstring binary required

If minorEdits is set to 'true', no notification email or activity stream will be generated when the attachment is added to the content.

Response

Returned if the attachments were added to the content.

startinteger
limitinteger
sizeinteger required
_linksGenericLinks required

Changes

No recorded changes to this operation across all 2 revisions of this API.