LogoLogo
HomePricingSign inRegister
  • PDFMonkey Documentation
  • Guides
    • From zero to generating your first Document
    • Generating your first Document with Zapier
    • Generating your first Document with Make
    • Making your first API call
  • PDFMonkey Features
    • 14-day Pro trial
    • Automatic deletion (TTL)
    • CLI
    • Generating images
    • Share links
    • Synchronous generation
    • Snippets
    • Webhooks
  • Frequent questions
    • Troubleshooting
      • My Document is blank
      • My data is not showing up in the Document
      • The Download URL is empty
    • What can you do with PDFMonkey?
    • What happens if I use all of my quota?
    • How do I change my password?
    • How do I delete my account?
    • Authoring Templates
      • Can I import an existing PDF or Word file in PDFMonkey?
      • What are the Template test data?
      • Can you create templates for me?
      • Can I display the number of the current page in the content?
      • Can I use links?
    • Privacy and security
      • What data do you keep and for how long?
      • How is my data secured?
      • Do you have a DPA
    • Compliance
  • How-tos
    • Adding a header or footer to your document
    • Including images in your documents
    • Styling your documents
      • Writing your own CSS
      • Using external libraries
      • Providing per-Document styles
      • Dealing with page breaks
    • Using different fonts
      • Handling special characters (UTF-8, Hebrew, Chinese, etc)
      • Using different fonts in header and footer
    • Using JavaScript
      • What are the available JavaScript features
      • JavaScript and Dynamic Data
      • Using external libraries
      • Displaying dates and time using JS
      • Including charts in your Documents
      • Debugging your JavaScript
    • Setting the filename of the generated Document
    • Changing the size of the page and its margins
    • Forcing a single page or use a full-page background
    • Using QR Codes
  • Integrations
    • List of integrations
    • Zapier
      • Generating your first Document with Zapier
      • Document generation options in Zapier
      • Reacting to generated documents in Zapier
      • TODO Retrieving a Document in Zapier
      • TODO Deleting a document using Zapier
      • Fixing frequent Zapier errors
    • Make (formerly Integromat)
      • Generating your first Document with Make
    • Workato
      • Generating a document with Workato
      • Deleting a document using Workato
      • Reacting to generated documents in Workato
    • Glide
    • Bubble
    • InvoiceBerry (via Zapier)
    • Ruby SDK
  • References
    • The Document Lifecycle
    • Liquid Reference
      • Introduction
      • Defining and using dynamic data
      • Variables
      • Naming variables
      • Conditions (if/else)
      • Iteration (dealing with lists)
      • Filters (data transformation)
        • Built-in filters
        • PDFMonkey filters
      • PDFMonkey Liquid tags
      • Whitespace control
    • API Reference
      • Documents
      • Templates
Powered by GitBook
On this page
  • Download URL expired
  • 422 Responses
  • Values containing double quotes
  • Values containing line breaks
  • Solution

Was this helpful?

  1. Integrations
  2. Zapier

Fixing frequent Zapier errors

PreviousTODO Deleting a document using ZapierNextMake (formerly Integromat)

Last updated 3 years ago

Was this helpful?

Download URL expired

If you get an expired Download URL error during the building of your Zap, try reloading the example record in your trigger.

Since the Download URL is only valid for 1h, you need to refresh the Documents in Zapier to get new Download URL. You can do so by clicking the Load More button in the Test section of your trigger.

Generation output

This tip is for the trigger but it will not apply for the output of a Generate Document action. Is this case you will need to generate a new Document in order to get fresh data and a valid Download URL.

422 Responses

This error will usually happen if you use the custom JSON option to write your Zap but have values that need escaping before being sent to PDFMonkey.

Values containing double quotes

Let's say you defined the following custom JSON:

Custom JSON
{
  "user": {
    "name": "(Dynamic Field From Zapier)"
  }
}

If the value in Dynamic Field From Zapier contains quotes, the constructed JSON will end-up broken. Let's take Peter "Spiderman" Parker as an example. Here is what the end JSON would look like:

Invalid JSON
{
  "user": {
    "name": "Peter "Spiderman" Parker"
  }
}

As we can see, it will not be a valid JSON payload when it's sent over the wire.

HTML attributes

If you send HTML for instance this will happen a lot as 99% of the time attributes use double quotes to set their value (ex: <div class="test">)

What you actually want is to escape those double quotes so that your JSON remains valid:

Valid JSON
{
  "user": {
    "name": "Peter \"Spiderman\" Parker"
  }
}

Values containing line breaks

JSON doesn't support values that include line breaks, so this is invalid JSON:

Invalid JSON
{
  "userBio": "Once upon a time,
They lived happily ever after."
}

What you want to do instead is escape those line breaks by either replacing them with a <br> tag or transform them to the text representation of a line break (\n).

Valid JSON
{
  "userBio": "Once upon a time,\nThey lived happily ever after."
}

Solution

Do you really need custom JSON?

The first question to ask yourself is "Do you really need custom JSON?". In most cases, the simple mapping approach will be good enough and will make your life easier as it will take care of escaping everything automatically.

If you can't escape the values before they reach Zapier, the next best solution is to add a Code by Zapier action before calling PDFMonkey.

Let's say you data contain both line breaks and double quotes and are looking like this:

Item
Value

Trigger App User Bio

This is the bio of the user.

It's a free form text that the user can edit so it can contain line breaks.

It could even be split in a few paragraphs… why not?

Trigger App User Name

Peter Parker

Trigger App User Full Name

Peter "Spiderman" Parker

Here we need to escape values for both Trigger App User Bio and Trigger App User Full Name. Let's start by adding a Code by Zapier action to our Zap and selecting Run Javascript :

We can now give our fields names that will help us identify them in the following steps:

And now we'll add the magic that will solve our issue, the actual code:

Code by Zapier
let data = Object.assign({}, inputData);

for (let key in data) {
  if (typeof(data[key]) === "string" && data[key].length > 0) {
    data[key] = data[key].replace(/\r?\n/g, '<br>').replace(/\t/g, " ").replace(/"/g, '\\\"');
  }
}

output = [data];

It will give you the same fields in the output but with their value properly escaped:

You can now use those values when building your PDFMonkey payload.

Notice how here we used the fields coming from the second step and not from the trigger.