Missed Team ’24? Catch up on announcements here.

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

How do I encode into a multipart/form-data the bytes of an image to add to a customer request?

Miguel Afonso
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 7, 2024

Hello,

I am trying to make a google sheets that, when appropriate, creates a ticket in jira's servicedesk. To communicate with the servicedesk API I am using google's apps script.

However, I am having an issue when adding a photo to the request. The photos show as the base64 encoding string opposed to want I want (the actual image).

I suppose that I am doing the encoding wrong, or the multipart/form-data format is also wrong.

The code for creating the multipart:

 

    const boundary = 'here';
    let formData = '';
    formData += `--${boundary}\r\n`;
    formData += `Content-Disposition: form-data; name=file; filename=${input.file.getName()}\r\n`;
    formData += `Content-Type: ${input.file.getContentType()}\r\n\r\n`;
    formData += Utilities.base64Encode(input.file.getBytes()) + '\r\n';
    formData += `\r\n--${boundary}--`;
The result: Screenshot (134).png
This resulting file has the PNG format like the original.

 

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events