Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Jira dosen´t decode base64 attachment-request (REST API)

Hello,

i am trying to send attachments from an external ticket-system (BMC ITSM-Suite) to Jira. My request is working. It adds an attachment to an existing issue. But it seems like Jira is not decoding the data which is send in base64.

This is my request:

--W3NByNRZZYy4ALu6xeZzvWXU3NVmYUxoRB
Content-Disposition: form-data; name="file"; filename="test.txt"
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64

[content of test.txt]
--W3NByNRZZYy4ALu6xeZzvWXU3NVmYUxoRB--

 

The content of my file is:

test

 

The content of the file in Jira is:

dGVzdA==

 

The content of the Jira file is the base64-coded content of the origin file.

Has someone had the same issue? Or has someone an idea what the problem could be?

Best Regards!

2 answers

1 accepted

0 votes
Answer accepted
Thomas Deiler Community Leader Oct 16, 2018

Dear @TieDall,

you have to envelope your attachment on your own. Jira doesn't process base64 files. So best you decode your attachment and then post them to the API:

See my Java snipplet for this:

import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.Header;

HttpPost postRequest = new HttpPost(url);
postRequest.addHeader(header);
MultipartEntityBuilder multipartEntity = MultipartEntityBuilder.create();
multipartEntity.setMode(HttpMultipartMode.STRICT);
multipartEntity.addBinaryBody("file", new File(path));
postRequest.setEntity(multipartEntity.build());

 So long

Thomas

Hi @Thomas Deiler,

the external ticket-system can only send the file coded in base64. I have no chance to change that.

Is their no way to decode the file in Jira?

Thomas Deiler Community Leader Oct 17, 2018

Dear @TieDall,

I have checked the documentation a second time. Base64 is accepted as a MulitPartEntity mesasge. So I guess, that somehow what you send to Jira does not comply to RFC2388. Best you check how for example curl sends attachments to Jira and then reimplement this in your case.

If this doesn't work, implement a small proxy service (or script), that accepts Base64 attachments, file name and target issue key, to do the job for you.

So long

Thomas

Thank you, @Thomas Deiler!

I didn´t find any errors in my request. I solved the problem by implementing a small proxy service, as you mentioned earlier.

Best regards!

Hi,  i am facing same issue and trying to attach the file , could you please share the proxy service you created 

Hi, @Muhammad Ramzan if you have a Jira server you can try to use our free addon from the marketplace which decodes your base64 encoded attachments.

https://marketplace.atlassian.com/apps/1221585/base64-attachment-upload-rest-api?hosting=server&tab=overview

Like Muhammad Ramzan likes this

Thanks  its amazing i installed and using it

Hi guys,

in case anyone else have this kind of problem. We just recently released on marketplace Base64 Attachment Upload app which is decoding base64 attachments data on Jira Server side.

So if you don't want to implement your own service just install app on Jira and use one of provided endpoints.

@Michal Patoprsty , unfortunately its not supporting the service desk customers.

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><base64AttachmentUploadResult>    <errorMessage>Current user does not have EDIT_ISSUES permission for issue with id ISD-2!</errorMessage>    <result>ERROR</result></base64AttachmentUploadResult>

@Muhammad Ramzan , thank you for notifying us about this use case.

We have looked into the lifecycle of attachments that are created using the customer portal (the only place where sd customers can interact with Jira SD).  It works a little bit differently than the usual attachment lifecycle.   Any attachment that is submitted by customer user is always a part of a request comment. 

The Atlassian supported way to add an attachment as a customer user to a request is to use this rest endpoint: https://docs.atlassian.com/jira-servicedesk/REST/4.13.1/#servicedeskapi/request/{issueIdOrKey}/attachment-createAttachment .  This endpoint uses temporary files created by endpoint https://docs.atlassian.com/jira-servicedesk/REST/4.13.1/#servicedeskapi/servicedesk/{serviceDeskId}/attachTemporaryFile .  And the attachTemporaryFile endpoint does not support Base64 encoded attachments.

We can provide an alternative implementation of attachTemporaryFile in our plugin that will support Base64 attachments.  This implementation will return temporary attachment ids that can be then used in a call to https://docs.atlassian.com/jira-servicedesk/REST/4.13.1/#servicedeskapi/request/{issueIdOrKey}/attachment-createAttachment .  Would that be sufficient for you?

Like Michal Patoprsty likes this

That would be awesome and i think your addon will get more attractions to those who integrating service desk with third party like BMC Remedy 

@Muhammad Ramzan Thank you for confirmation, we will soon release a version of our plugin that will support creating temporary attachment / file ids.

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you