Best answer

download file locally from Zapier app Action - Fattura24

  • 18 November 2020
  • 6 replies
  • 1608 views

Userlevel 1

In my Zapier App - that’s Fattura24, I would like to add an action called ‘GetFile’.
First of all y add an Input field in which I could enter a document Id;

then I call my API in a way like this:

endpoint: URL: https://www.app.fattura24.com/api/v0.3/GetFile

params: { apiKey: xxxxxxxxxx,

              docId: 123456 }

 

The result of this call is actually a PDF file identified by docId.

I would like to build a method by which the user can download (or prompted to do so) the file in his desktop. Any suggestion?

Thanks to all

icon

Best answer by ikbelkirasan 19 November 2020, 18:31

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

6 replies

Userlevel 7
Badge +12

@Davide Unfortunately, I haven’t built app in the Legacy Web Builder. However, it might be useful to look at this example app: https://github.com/zapier/zapier-platform/blob/master/example-apps/files/triggers/newFile.js

Userlevel 1

@ikbelkirasan 
Now I’d like to build my GetFile action in a way that its result looks like the result I get by using Webhooks, that is the object ‘File’ ?

 

I tried to add this in my scripting:

 

 // Action 'Get File'
get_file_pre_write: function(bundle)
{
var pjson = require('package.json');
var fields = bundle.action_fields_full;
var keys = Object.keys(fields);
var docId = fields[docId];
var apiKey = bundle.request.params.apiKey;

bundle.request.params =
{
apiKey: apiKey,
docId: docId,
source: 'F24-Zap ' + pjson.version
};
return bundle.request

},

get_file_post_write: function(bundle)
{
return bundle.response;
},

When I test this code as a result I don’t get the File

Userlevel 1

Hi @Davide - While this might not be possible with a custom integration action, you might want to consider the following options:

  • Build a zap that saves the file to the user’s Dropbox (or Google Drive etc..) folder that’s automatically syncing with their computer.
  • Build a zap that sends them the download link in an email or in a Slack message.


At last I solved by adding two steps in my Zap:

  1. Zapier webhooks to post my request;
  2. Email by Zapier to send the result of the previous step as attachment

Thank you very much for your support

Userlevel 7
Badge +12

@Davide The problem here is that Zapier doesn’t work in Request-Response fashion so you can’t actually respond to HTTP requests with a custom response.

Userlevel 1

Actually I need only something like opening an URL in a new browser tab, with a string like this  in address bar:

 

https://www.app.fattura24.com/api/v0.3/GetFile?apiKey=xxxx&docId=123456

 

any suggestion?

Userlevel 7
Badge +12

Hi @Davide - While this might not be possible with a custom integration action, you might want to consider the following options:

  • Build a zap that saves the file to the user’s Dropbox (or Google Drive etc..) folder that’s automatically syncing with their computer.
  • Build a zap that sends them the download link in an email or in a Slack message.