Unable to call AWS Textract AnalyzeDocument via HTTP Request or AWS Lambda in n8n – Need guidance

I’m trying to extract table data from PDF files using AWS Textract’s AnalyzeDocument operation, directly from an n8n workflow.


:wrench: My Goal:

Use either:

  • :white_check_mark: HTTP Request Node
    OR
  • :white_check_mark: AWS Lambda Node
    …to send a base64-encoded PDF to AWS Textract and get the result with "FeatureTypes": ["TABLES"].

:open_file_folder: My Workflow:

  • Webhook receives PDF (binary.file0)
  • Convert PDF to base64 inside n8n
  • Either:
    • Send it directly to Textract endpoint via HTTP Request
    • Or send it to an AWS Lambda function that wraps the Textract API
  • Process the response and extract SKU/Price

:x: What’s not working:

:one: When using HTTP Request Node:

  • Endpoint: https://textract.us-east-1.amazonaws.com
  • Headers:
    • X-Amz-Target: Textract.AnalyzeDocument
    • Content-Type: application/x-amz-json-1.1
  • Body:

json

CopyEdit

{
  "Document": {
    "Bytes": "base64 string"
  },
  "FeatureTypes": ["TABLES"]
}
  • Authentication: AWS (credentials with AmazonTextractFullAccess)

I get errors like:

  • 403 Forbidden – UnknownOperationException
  • 400 – Invalid Parameters
  • Or "Bytes": "=" because expressions are not evaluated properly in n8n

:two: When using AWS Lambda Node:

  • I created a working Lambda that calls Textract using the SDK
  • If I call it from Postman or CLI – it works fine
  • But from n8n, I get:
    • "Missing 'base64' field"
    • or "Request has invalid parameters"
    • or the body is sent as =, not evaluated expression

Even after setting the expression in the JSON Input field (Ctrl+E, JSON.stringify(...)) — the values are not calculated or passed properly to Lambda.


:brain: Summary:

I’ve tried both methods (HTTP + Lambda) to interact with AWS Textract inside n8n — neither works properly due to what appears to be expression evaluation or AWS Signature/Auth issues.


:pray: What I need:

  • Can you please explain the correct method to call AWS Textract’s AnalyzeDocument (FeatureTypes: [“TABLES”]) from n8n?
  • Is the HTTP Request node capable of signing that request correctly?
  • Is the AWS Lambda node capable of passing a base64-encoded file in a valid way?

Even a working .json example would help a lot.


Thank you for your time and help!

Best regards,
Pierre


In your last screenshot, the json input is weird according to:
it has an fx sign which means an expression so it should be surrounded by {{ }}

But still not sure if binary encoding to base64 will be the correct input. at least it would need to parse the result correctly just under that field, now it just takes it literal

and please share your workflow in a correct way.

reg,
J.

{
“nodes”: [
{
“parameters”: {
“httpMethod”: “POST”,
“path”: “ae967fad-e0d4-40ad-aa4b-69f5da2ad285”,
“options”: {
“binaryPropertyName”: “file”
}
},
“type”: “n8n-nodes-base.webhook”,
“typeVersion”: 2,
“position”: [
-560,
440
],
“id”: “430e9e21-98f6-4112-9354-59d63947f6e9”,
“name”: “Webhook1”,
“webhookId”: “ae967fad-e0d4-40ad-aa4b-69f5da2ad285”
},
{
“parameters”: {
“options”: {}
},
“type”: “n8n-nodes-base.convertToFile”,
“typeVersion”: 1.1,
“position”: [
1580,
260
],
“id”: “419d9266-b7ca-40ed-9148-01e2b64437d8”,
“name”: “Convert to File4”
},
{
“parameters”: {
“rules”: {
“values”: [
{
“conditions”: {
“options”: {
“caseSensitive”: true,
“leftValue”: “”,
“typeValidation”: “strict”,
“version”: 2
},
“conditions”: [
{
“leftValue”: “={{ $binary.file0.fileExtension }}”,
“rightValue”: “pdf”,
“operator”: {
“type”: “string”,
“operation”: “endsWith”
},
“id”: “6e0a8703-0e3b-460e-a1e0-681340ee613e”
}
],
“combinator”: “and”
},
“renameOutput”: true,
“outputKey”: “PDF”
},
{
“conditions”: {
“options”: {
“caseSensitive”: true,
“leftValue”: “”,
“typeValidation”: “strict”,
“version”: 2
},
“conditions”: [
{
“id”: “a393a6d7-2a68-4400-ab18-39492a527d55”,
“leftValue”: “={{ $binary.file0.fileExtension }}”,
“rightValue”: “xlsx”,
“operator”: {
“type”: “string”,
“operation”: “endsWith”
}
}
],
“combinator”: “and”
},
“renameOutput”: true,
“outputKey”: “XLSX”
},
{
“conditions”: {
“options”: {
“caseSensitive”: true,
“leftValue”: “”,
“typeValidation”: “strict”,
“version”: 2
},
“conditions”: [
{
“id”: “6b386558-bd48-40a2-8299-c9e0d80518cc”,
“leftValue”: “={{ $binary.file0.fileExtension }}”,
“rightValue”: “txt”,
“operator”: {
“type”: “string”,
“operation”: “endsWith”
}
}
],
“combinator”: “and”
},
“renameOutput”: true,
“outputKey”: “TXT”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.switch”,
“typeVersion”: 3.2,
“position”: [
-120,
440
],
“id”: “1861cd66-5dd9-41b4-bec3-ceffac8aa530”,
“name”: “Switch”
},
{
“parameters”: {
“function”: “arn:aws:lambda:us-east-1:836848257439:function:textract-table-parser”,
“payload”: “=Buffer.from($binary.file0.data, ‘binary’).toString(‘base64’)”
},
“type”: “n8n-nodes-base.awsLambda”,
“typeVersion”: 1,
“position”: [
860,
260
],
“id”: “056491e5-9785-4513-9aea-6c3b418025bc”,
“name”: “AWS Lambda”,
“credentials”: {
“aws”: {
“id”: “QJIXXTdklAm67z5r”,
“name”: “AWS account”
}
}
},
{
“parameters”: {
“jsCode”: “const blocks = JSON.parse($json.body).Blocks || ;\nconst cells = blocks.filter(b => b.BlockType === ‘CELL’);\n\nconst skus = ;\nconst prices = ;\n\ncells.forEach(cell => {\n const text = cell.Text?.trim();\n\n if (text && /^\d{4,}-?\d*$/.test(text)) {\n skus.push({ row: cell.RowIndex, sku: text });\n }\n if (text && /^\$?\d+(\.\d{1,2})?$/.test(text)) {\n prices.push({ row: cell.RowIndex, price: text });\n }\n});\n\nconst results = ;\n\nskus.forEach(s => {\n const match = prices.find(p => p.row === s.row);\n results.push({\n json: {\n SKU: s.sku,\n Price: match ? match.price : "MISSING"\n }\n });\n});\n\nreturn results;\n”
},
“type”: “n8n-nodes-base.code”,
“typeVersion”: 2,
“position”: [
1260,
260
],
“id”: “5a6c1f7e-7136-4c60-b4c5-074cd795a191”,
“name”: “Code”
}
],
“connections”: {
“Webhook1”: {
“main”: [
[
{
“node”: “Switch”,
“type”: “main”,
“index”: 0
}
]
]
},
“Switch”: {
“main”: [
[
{
“node”: “AWS Lambda”,
“type”: “main”,
“index”: 0
}
],
,

]
},
“AWS Lambda”: {
“main”: [
[
{
“node”: “Code”,
“type”: “main”,
“index”: 0
}
]
]
},
“Code”: {
“main”: [
[
{
“node”: “Convert to File4”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateId”: “PT1i+zU92Ii5O2XCObkhfHJR5h9rNJTpiCIkYJk9jHU=”,
“templateCredsSetupCompleted”: true,
“instanceId”: “0013d54e62576517a55723fae121fede2727abb497f99f3dc0406e8214740bb9”
}
}

I had the same problem but for a different service of AWS. AWS requires sig4 auth. There is a problem in n8n. You have to use a built in N8n connector of aws to connect instead of HTTP request.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.