How to download freshdesk ticket attachments to upload to remote API?

Hello!

I’ve created an app that creates a task in teamwork from freshdesk ticket. Currently I’m working on a feature to pick ticket attachments and attach them to task in teamwork, but I’ve ran into problem as I cannot find a way to download the file to upload it to teamwork.

Is there maybe an example app that deals with file (ticket-attachment) downloading/uploading.

2 Likes

Hi @Peteris_Kuskis,

This requires both HTTP library and file storage to support file download and upload. The following posts could clarify why Request method of our platform and Serverless cannot support file downloads and uploads.

  1. How to create a ticket with attachments using request API?
  2. Error Received: Source.on is not a function

File upload is possible only if it can be converted as readable stream to upload to third-party without needing to store locally in the Serverless app. Currently, we do not have any samples for this (Please up vote the post #1 for requesting it).

2 Likes

I’ve used the following structure to get a link from an external api and generate an attachment on a freshdesk ticket on a serveless!

Getting the ticket attachment to send to another api I never tested, but maybe that helps:

indent preformatted text by 4 spaces
   var   unirest  =  require('unirest');
   update_ticket(args){
	var domain = args.iparams.domain;
	var api_key = args.iparams.api_key;

	var url = `${domain}/api/tickets/${args.id}`;		
	var headersOpt = {  
		"Authorization": "Basic "+base64.encode(`${api_key}:x`)
	};		
	unirest.put(url)
		.headers(headersOpt)
		.attach('attachments[]', args.url_attachment)
		.end(function (response) {
			console.log(response.body);
			if (response.status === 200) {	
				renderData(null,{"body": response.body, "status": response.status});
			}else{
				renderData(null,{"body": response.body, "status": response.status});
			}
		});
}
5 Likes

@Peteris_Kuskis,

Let us know if suggestions from @Raviraj or @Marllon_Mainardes have helped you make some progress.

2 Likes