I need to capture an array of items and use them inside the JSON request body of the HTTP module:
The items need to be added to the http request body in JSON format (exactly as they are shown now, but without the array brackets), without clobbering the JSON that I already have in the request body.
Currently if I try to reference inside the request body I can only get one value at a time.
The reason for this is I am trying to add new line items to an existing QuickBooks invoice, and the current QuickBooks node does not support adding line items.
Unfortunately, the QuickBooks API also requires you to preserve the existing transaction IDs in the request body otherwise they get deleted and replaced with the new one - so I am also not able to loop my http request.
What’s the best way to accomplish this? Also, if anyone knows of a better way to accomplish adding new line items to a QBO invoice using N8N please share.
What is the error message (if any)?
Please share the workflow
Share the output returned by the last node
Information on your n8n setup
n8n version: 0.198.2
Database you’re using (default: SQLite): Postgres
Running n8n with the execution process [own(default), main]: own
Running n8n via [Docker, npm, n8n.cloud, desktop app]: k8s
@joeldeteves happy to hear you found a solution. Prior to discovering the Item Lists node, can you remember what you thought you were looking for?
Basically what search term/ how were you thinking about the problem prior to finding Item Lists node? We can add alias search terms to any node, so would be helpful to know. This way we can make it more discoverable for others in future
Check customer subscriptions in our CSP partner portal
Add subsriptions to the invoice (matched by SKU)
Email invoice to the client
The main challenge was rebuilding the QBO Item List - QuickBooks API uses an array to store this information and the only way to “add” an line item is to capture the existing line items and include them in your query, otherwise all the existing line items are overwritten / removed.
Therefore I needed to capture that data, combine it with my new data and re-construct it into JSON for the final HTTP request.
I guess I was originally trying to do this using a SET node, when in fact I needed several SET nodes and an Item Lists node using the aggregate feature to combine them.
I think the best solution would be to update the QuickBooks node to have an “Add Line Item to Invoice” feature - that would eliminate a ton of the logic being used here.
But overall, I guess you would want to add the search term “combine” and “aggregate” to the Item Lists node - those are definitely things that are useful when pulling data from multiple sources and re-constructing into a single field.