Base64 Attachment REST API v1.1

This plugin provides a REST API that allows upload of Base64 encoded attachments:

  • Direct - allows direct upload of Base64 encoded attachments where metadata are stored in URL

  • JSON - allows upload of Base64 encoded attachments where both attachment and metadata are stored in JSON structure

Authentication

Both direct and JSON endpoints require preemptive basic authentication.

Direct endpoint

/rest/base64attachment/1.0/direct/{issueIdOrKey}/{filename}/

Allows direct upload of Base64 encoded attachments where metadata are stored in URL.

The URL can be parametrized as follows:

  • {issueIdOrKey} - path parameter that should be replaced with the issue id or key

  • {filename} - path parameter that should be replaced with filename that will be displayed in Jira

Additionally, following optional query parameters may be used:

  • contentType - if used, then Jira will store this content type for the uploaded attachment.  If not specified, then internal Jira functionality will decide best content type for uploaded attachment.

  • zipFlag - if used, then the zip flag will be passed to Jira to indicate that the uploaded attachment is a zip archive.

Example:

JSON endpoint

/rest/base64attachment/1.0/json

Allows upload of Base64 encoded attachments where both attachment and metadata are stored in JSON structure.

The JSON structure included in body can be parametrized as follows:

  • issueIdOrKey - required parameter, should be replaced with the issue id or key

  • base64EncodedData - required parameter, should contain base64 encoded attachment data

  • filename - required parameter, should be replaced with filename that will be displayed in Jira

  • contentType - optional parameter, if used then Jira will store this content type for the uploaded attachment (If not specified, then internal Jira functionality will decide best content type for uploaded attachment)

  • zipFlag - optional parameter, if used then the zip flag will be passed to Jira to indicate that the uploaded attachment is a zip archive

Example:

URL

http://localhost:8080/rest/base64attachment/1.0/json

Method

POST

Content Type (HTTP Header)

application/json

Body

{ "issueKeyOrId" : "SAM-43", "base64EncodedData" : "SGVsbG8gd29ybGQhCg==", "filename" : "sample.txt", "zipFlag" : "false", "contentType" : "text/plain" }

API Response

This chapter describes the structure of response that is returned by all API endpoints.

Success

All endpoints respond with a JSON response that contain following fields when the API request was processed successfully:

  • result - OK, when attachment was correctly created

  • attachmentId - attachment ID (Note: SD Customer endpoint does not return attachment ids)

Example:

{"result":"OK","attachmentId":"10118"}

Error

All endpoints respond usually with a JSON response that will contain following fields when the API request processing failed:

  • result - ERROR

  • errorMessage - error message

The HTTP status code of an error response will be in the 4** or 5** range.

Example:

{"result":"ERROR","errorMessage":"IssueIdOrKey parameter can not be null!"}

On this page: