InvoiceNinja and "line_items" - Why dont I see it?

Describe the problem/error/question

I am creating a n8n workflow that takes an array input and should create line items for my single invoice. However, the CREATE action for INVOICE doesnt allow me to input a Line_items json. GPT suggests using line_item and then passing on my array from the previous node as input, but I dont see it. What could be the reason and how to enable it?

My n8n is a cloud subscription and I am running version [email protected]

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

hello @TheTweakyTales

You can’t add a JSON, the node works only with manually added items

Hi @TheTweakyTales ,

this node has a really strange design to POST invoice data!
As @barn4k already mentioned it is not possible to add a JSON-array.
But it is possible to do it like “hardcoded”:
You can add several item-lines in this node manually and map them with your source-JSON item by item. (you have to add as much item lines as you ever expect to get + 1.)

{
“nodes”: [
{
“parameters”: {
“jsCode”: “const lineItems = [\n {\n item: 1,\n product: \“TSL-001\”, // Use Project ID as Product name\n description: \“Rushil Ranade Speaker 9/9/25\”,\n quantity: 1,\n unit_cost: 60\n },\n {\n item: 2,\n product: \“2TSL-001\”, // Use Project ID as Product name\n description: \“2Rushil Ranade Speaker 9/9/25\”,\n quantity: 2,\n unit_cost: 260\n }\n];\n\n// Return as JSON\nreturn [{ json: { line_items: lineItems } }];\n”
},
“type”: “n8n-nodes-base.code”,
“typeVersion”: 2,
“position”: [
-336,
-96
],
“id”: “dbb29bc3-a85c-4f3e-be82-c29918b606b5”,
“name”: “Code”
},
{
“parameters”: {
“apiVersion”: “v4”,
“resource”: “invoice”,
“additionalFields”: {},
“invoiceItemsUi”: {
“invoiceItemsValues”: [
{
“cost”: “={{ $json.line_items[0].unit_cost }}”,
“description”: “={{ $json.line_items[0].product }}”,
“service”: “={{ $json.line_items[0].description }}”,
“hours”: “={{ $json.line_items[0].quantity }}”,
“taxName1”: “test1”,
“taxName2”: “test2”
},
{
“cost”: “={{ $json.line_items[1].unit_cost }}”,
“description”: “={{ $json.line_items[1].product }}”,
“service”: “={{ $json.line_items[1].description }}”,
“hours”: “={{ $json.line_items[1].quantity }}”
}
]
}
},
“type”: “n8n-nodes-base.invoiceNinja”,
“typeVersion”: 2,
“position”: [
-64,
-96
],
“id”: “0b5910f9-42a1-482e-af0b-bce4835e9d18”,
“name”: “Create an invoice”,
“credentials”: {
“invoiceNinjaApi”: {
“id”: “ZfReHvm6dIxhGPBN”,
“name”: “Invoice Ninja account”
}
}
}
],
“connections”: {
“Code”: {
“main”: [
[
{
“node”: “Create an invoice”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “4899eafb2fab96cf9ff1b247890aa6332ec458e77189f0aa0b55b2cbb85a4c41”
}
}

Another option is using a http-node to make an custom api request.
This should make it possible to pass an array with line items.

I managed to get this use case solved by doing a HTTP POST to the API of InvoiceNinja and then passing all my line_items as an array to create individual line items in my invoice.

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