Best answer

How do I download PDF files to a OneDrive folder?


Userlevel 1

Background:

We have been using Printavo to manage our screen print/embroidery shop.  We have a couple of large customers for jobs completed within the last two weeks.

 

I would like to;

  1. Identify jobs for Customer A that are complete
  2. Find the URL to the actual invoice.pdf for that job
  3. Download the file to a OneDrive folder

1 and 2 are not the issue; I’m damned if I can find the easy, straightforward way to accomplish 3.  I have the URL, I have the OneDrive connected.  I need the rough equivalent of 

 

#!/bin/sh

pdfout = $(uuidgen).pdf
curl -o $pdfout $1

where $1 points to the PDF I need.

 

thanks.

icon

Best answer by christina.d 4 June 2022, 04:59

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.

18 replies

Userlevel 7
Badge +14

Hi @spectrum 

Good question.

Help article about using files in Zaps: https://zapier.com/help/create/basics/send-files-in-zaps

Please post screenshots with how your Zaps steps are configured in order for us to have context, thanks.

Userlevel 1

Thank you.  That’s helpful.  Unfortunately now I’m seeing an error:

The Content-Range header is missing or malformed

 

The URL is of the form

https://path/to/pdf/file.pdf


Edit:

I see the problem.  That’ll open directly in my browser.  I need a way to download it, then send it to OneDrive.

Userlevel 7
Badge +14

@spectrum 

The file URL must be publicly accessible in order to be used in Zaps.

The image you attached could not be viewed.

Perhaps you can post screenshots again with how your Zap steps are configured.

Userlevel 1

The URL is publicly available.  Trying again with the screen shot.  

 

screen shot - upload file action

 

Userlevel 7
Badge +14

@spectrum 

If it’s a view link to the PDF, then that won’t work.

It needs to be a direct download link to the PDF.

Userlevel 1

Yes, that was my conclusion.  Surely there is a way to do this, short of rolling the Printavo API into my own shell script (which I would prefer not to do)?

 

Userlevel 7
Badge +14

@spectrum 

Often a workaround includes determining what the download File URL is and possibly dynamically generating that from the provided PDF URL.

 

Userlevel 1

As near as I can tell, the provided PDF URL *is* the file.

curl -o ~/Desktop/temp.pdf https://spectrumdesigns.printavo.com/invoice/<UUID string>.pdf

will put the PDF on my desktop.

I’ve tried this using Google Drive instead of OneDrive. No error, but I get the parent HTML instead of the actual PDF -- as if I asked for

curl -o ~/Desktop/temp.pdf https://spectrumdesigns.printavo.com/invoice/<UUID string>

(same URL without “.pdf” at the end)

Userlevel 1

Aha.  The Zapier field (Pdf) -- which should contain the download link to the actual file, and appears to in the editor -- is actually giving me the parent page.  Verified this by pasting the expected URL instead of using the field value.

How do I fix this?

 

Userlevel 7
Badge +14

@spectrum 

Not sure I follow.

What is a real example of the provided PDF URL vs the expected PDF URL?

Userlevel 1

What I expect:

https://spectrumdesigns.printavo.com/invoice/9068822646332425a3555e8be338fbd4.pdf

 

What I am getting:

https://spectrumdesigns.printavo.com/invoice/9068822646332425a3555e8be338fbd4

 

Userlevel 7
Badge +14

@spectrum

Did you try just appending .pdf to the end?

e.g. [PDF_URL].pdf

Userlevel 1

yes.  No joy.  Appending .pdf to the end still throws an error (OneDrive).

 

Here’s a screen shot -- some of the available values, including the one I want (fifth line down):

 

 

Userlevel 7
Badge +14

@spectrum 

Worked for me when testing.

 

OneDrive Upload File step configuration (granted it’s a static value), but if you map the correct variable for the PDF, it should work.

 

Screenshots from the uploaded file in OneDrive.

 

Userlevel 1

Huh.  That’s exactly what I’ve been doing.  It worked when I pasted the URL.  It does not work when I use the variable/PDF field.

I see now that the variable field is incorrect -- it says “www’ where it should say “spectrumdesigns”.  The “www.printavo.com” page is nothing more than an HTML redirect to the parent page:

<html><body>You are being <a href="https://spectrumdesigns.printavo.com/invoice/9068822646332425a3555e8be338fbd4">redirected</a>.</body></html>

Looks like I’ll have to use Javascript or Python to get this done.

Userlevel 7
Badge +14

@spectrum

Add a Zap step: Formatter > Text > Replace

Replace “https://www.” with “https://spectrumdesigns.”

Userlevel 1

Thank you.  That does it!  Thank you for your help.

 

Userlevel 7
Badge +9

So glad to hear you were able to get this sorted, @spectrum!  

I also wanted to summarize some of the recommendations here into one solution in case it’s easier for anyone following along!

 

OneDrive Upload File step configuration (granted it’s a static value), but if you map the correct variable for the PDF, it should work.

 

Screenshots from the uploaded file in OneDrive.

 

In this case, since the URL in question is a redirect another step was required:

Add a Zap step: Formatter > Text > Replace

Replace “https://www.” with “https://spectrumdesigns.”

Thanks again and welcome to the Community! 🎉