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:
Code: HTML generierenNode: This node is now green. It generates the HTML string, and I’ve implemented thereplace(/"/g, "'")to convert double quotes to single quotes as recommended byhtml2pdf.appsupport 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.Code: PDF Body vorbereitenNode: This node is also green. It correctly prepares the JSON object for the request body, including the HTML content, filename, printBackground, and margins.HTTP Request2Node 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:
ONContent-Type: application/jsonX-API-Key: [MY_API_KEY_HERE](I’ve copied the key directly from myhtml2pdf.appdashboard 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).
- Body Content Type:
html2pdf.appSupport 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!