Base64 Attachment REST API v1.2
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
SD Customer - allows upload of Base64 encoded attachments where both attachment and metadata are stored in JSON structure as a comment created by a Jira Service Desk / Manager Customer
Authentication
All endpoints require preemptive basic authentication.
REST Endpoints
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:
URL | |
---|---|
Method | POST |
Content Type (HTTP Header) | text/plain |
Body | SGVsbG8gd29ybGQhCg== |
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 the body can be parameterized 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 | |
---|---|
Method | POST |
Content Type (HTTP Header) | application/json |
Body | {
"issueKeyOrId" : "SAM-43",
"base64EncodedData" : "SGVsbG8gd29ybGQhCg==",
"filename" : "sample.txt",
"zipFlag" : "false",
"contentType" : "text/plain"
} |
SD Customer endpoint
/rest/base64attachment/1.0/sdcustomer/json
Warning: The SD Customer endpoint is experimental and may stop working in future releases of Jira Service Desk / Manager and may remain unusable. Endpoint implementation utilizes experimental and internal Jira APIs due to the fact that no stable Jira Java API is available that provides this functionality. Use at your own risk!
Allows upload of Base64 encoded attachments where both attachment and metadata are stored in JSON structure as a public comment created by a Jira Service Desk / Manager Customer.
The JSON structure included in the body can be parameterized as follows:
issueIdOrKey - required parameter, should be replaced with the issue id or key
additionalComment - required parameter, comment body as plain text
files - an array of attachments
base64EncodedData - required parameter, should contain base64 encoded attachment data
filename - required parameter, should be replaced with a 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)
Example:
URL | http://localhost:8080/rest/base64attachment/1.0/sdcustomer/json |
---|---|
Method | POST |
Content Type (HTTP Header) | application/json |
Body | {
"issueKeyOrId" : "SOP-2",
"additionalComment" : "ajdfjsafajs",
"files" : [
{
"base64EncodedData" : "SGVsbG8gd29ybGQhCg==",
"filename" : "abc.txt",
"contentType" : "text/plain"
},
{
"base64EncodedData" : "SGVsbG8gd29ybGQhCg==",
"filename" : "cde.txt",
"contentType" : "text/plain"
}
]
} |
API Response
This chapter describes the structure of the response that is returned by all API endpoints.
Success
All endpoints respond with a JSON response that contains the following fields when the API request was processed successfully:
result - OK, when the attachment was correctly created
attachmentId - attachment ID (Note: SD Customer endpoint does not return attachment ids)
Example:
Error
All endpoints respond usually with a JSON response that will contain the 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:
On this page: