Sending Base64 encoded file through unirest

Hello all,

I am working with a client that wants to setup a middleware for ticket attachments. They are sending a Base64 encoded file to the middleware, which should then be sent to Freshservice via an API call. They can only send the file information in the following object (fields have been changed to mask proprietary values):

  "sys_id": "1234567890123467890",
  "file_name": "Test document.docx",
  "uploaded_by": "test.user",
  "size": "13225",
  "content_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",

In this object the “content” field contains the Base64 encoded file data.

I have attempted to setup the following function:

app.put('/api/ticket-integration/v1/tickets/:id/attachments', jsonParser, (req, res) => {

    .put("https://(my domain)" +
        "Authorization" : "Basic (my encoded API key)",
        "Content-Type" : "multipart/form-data",
    .attach('attachments[]', req.body.content,
            filename: req.body.file_name,
            contentType: req.body.content_type,
            knownLength: req.body.size,
    .end(function (response) {
        if (response.status < 400) {        
            console.log(`Attachment upload successful on ticket ${}.`);
            res.status(200).send('Attachment uploaded successfully' + JSON.stringify(response));
            console.log({"attachment body": response.body, "attachment status": response.status});

This gives me the following error

      throw er; // Unhandled 'error' event
Error: ENOENT: no such file or directory, open 'C:/file/path/(Base64 encoded file contents)'

I am not sure what value to put in the unirest call instead of req.body.content, but I know that is should be the file path. I am also not sure if it is even possible to send encoded files through the Freshservice API.

Has anyone found a way to be able to send this through?

Please let me know if there is any additional information I can provide, and thank you for taking the time to look through my post.

Hi @Jose_Escobar,

I’m not sure whether this API supports file upload as a Base64 string. The API docs only has example with file uploaded from a local or a remote path.

I have raised a support ticket for Freshservice for the recommended payload for Base64 file upload if it is supported here (#15867739) on your behalf.

I will also try to mimic and check if there are any way to upload the file this way.