Authorization failed" (HTTP 401) with html2pdf.app API and X-API-Key header

Hello n8n Community,

I’m encountering a persistent “Authorization failed - please check your credentials” error (HTTP 401 Unauthorized) when trying to integrate with the html2pdf.app API from my n8n.cloud workflow. I’ve been troubleshooting this for a while and could use some external expertise.

Workflow Overview: My workflow generates an HTML string, prepares a JSON body for html2pdf.app , and then sends a POST request to their API to convert the HTML to PDF.

Problem: The HTTP Request2 node consistently fails with a 401 Unauthorized error.

Steps I’ve already taken & Observations:

  1. Code: HTML generieren Node: This node is now green. It generates the HTML string, and I’ve implemented the replace(/"/g, "'") to convert double quotes to single quotes as recommended by html2pdf.app support to resolve a previous “html must be a string” error. This previous error is now gone, indicating the HTML content and body format are correctly received by the API.
  2. Code: PDF Body vorbereiten Node: This node is also green. It correctly prepares the JSON object for the request body, including the HTML content, filename, printBackground, and margins.
  3. HTTP Request2 Node Configuration:
  • Method: POST
  • URL: https://api.html2pdf.app/v1/generate
  • Authentication: None
  • Send Query Parameters: OFF (No query parameters are sent, as filename and other options are in the body).
  • Send Headers: ON
    • Content-Type: application/json
    • X-API-Key: [MY_API_KEY_HERE] (I’ve copied the key directly from my html2pdf.app dashboard multiple times to rule out typos or hidden characters, e.g., d4CtasfqTDITep2fLnFmfHEsskkZz3aCu3ZDcjGDY7AGlNON5XfMp4sxdp5TwwbB ).
  • Send Body: ON
    • Body Content Type: JSON (not Raw)
    • Specify Body: Using JSON
    • JSON Content: {{ $json }} (This correctly sends the JSON object prepared by the previous Code node).
  1. html2pdf.app Support Interaction: Their support confirmed my API key is correct. Their latest suggestion was to check the response status, which is indeed 401 Unauthorized.

Current Hypothesis: Given that the “html must be a string” error is resolved (meaning the body is correctly parsed) and html2pdf.app support confirms my API key, it seems there might be a very subtle issue with how n8n sends the X-API-Key header that html2pdf.app 's API is not accepting, or a server-side issue on their end specific to n8n.cloud requests.

Could someone please review my workflow JSON and configuration? Has anyone successfully integrated with html2pdf.app using X-API-Key in headers from n8n.cloud? Are there any known quirks or specific settings I might be missing for header transmission?

Thank you in advance for any insights!

You are supposed to send a link of the website. Not a HTML string.
So, you have to host the file somewhere. Follow these steps:

  1. Just create github account
  2. upload a html file over there. Then get the production link from raw.githack.com.
  3. Then, setup an automation to edit/update the html file on your github using N8N using github node.
  4. Then send the link you got from step 2 in the HTTP request to html2pdf.app

If it’s confusing, let me know