Run WF on a list which is an ARRAY in a JSON payload

Hi All,

Been wrestling this for too long. Time to ask the experts.

I want to process an INVOICE sent in JSON format that has a nested ARRAY.

  1. Created exposed wf to accept an INVOICE in JSON format
  2. INVOICE has a header and a nested ARRAY called InvoiceLines
  3. InvoiceLines data fields match exactly to a thing in my database called “InvoiceLines”
  4. Set up wf called “postinvoice” and set input parameter “InvoiceLines” as an “array” and “type” = InvoiceLines (the thing destination in my database)
  5. Set up wf #2 to process the lines: Running wf postinvoicelines on a list (InvoiceLines) - the idea that each list item in InvoiceLines will be created as an invoice line item in my thing InvoiceLines
  6. Finally, after each line is created, add that line to the Invoice (header) using the “add” feature (InvoiceLines is a list on my Invoice header)
  7. Send this JSON payload to /wf/postinvoice via Postman:

{
“customerOrgID”: 63,
“SupplierSubmittedDate”: “2025-06-16”,
“InvoiceNumber”: “12345”,
“supplierName”: “&”,
“subTotal”: 900,
“TaxTotal”: null,
“TaxRate”: 0,
“shippingCost”: null,
“Disc%”: null,
“Discount”: null,
“PONumber”: “XXXX001”,
“RemittanceAdv”: “Briard Bank, Account Name: Samira Hadid, Account No: 123-456-7890, Pay by: 5 July 2025”,
“Rebate”: null,
“InvoiceTotal”: 500,
“Comments”: null,
“InvoiceLines”: [
{
“partName”: “Apple iPhone 9”,
“partNumber”: “1283182389”,
“price”: 455.66,
“qty”: 1,
“total”: 455.66
},
{
“partName”: “Case 8”,
“partNumber”: “05394955”,
“price”: 55.66,
“qty”: 2,
“total”: 111.00
}
]
}

Resulting in an error where Bubble expects the Array to contain the uniqueId of the invoice lines BEFORE!! they have been created.

Error Message:
{
“statusCode”: 400,
“body”: {
“status”: “MISSING_DATA”,
“message”: “Invalid data for key InvoiceLines: object with this id does not exist: [object Object]”
}
}




using this setting, you will need to send the InvoiceLines as an array of Bubble thing unique ID like [“12345678x1234678”,“123456789x123456789”]. Pretty sure this is not what you are trying to do.
Instead, switch the manual definition to detect, send a test payload to the endpoint, and let Bubble parse it. However, you may face some issue to Schedule API On list because this type will not exist.

Workaround is to use API Connector set as data and to do a GET request to the API provider (if possible) using the Invoice Number to get the same payload, but using API Connector. At this moment, you should be able to Schedule on a list because Bubble will create a kind of “Thing” from API Connector.

There’s more workaround that exist like storing the JSON in DB and use a JSON plugin or send the array (as json) to another Backend WF (always using auto detect request data).

1 Like

Thank you for your insight and suggestions Jici,

I should have added that I tried auto parameter detection but the array for InvoiceLines actually is a list of InvoiceLines uniquIds and not the parameters themselves.

I will explore the idea of storing the JSON and extract the ARRAY and then send it to another wf. Thinking about this, I might just be able to extract with regex from the original payload inside of the original wf.

Appreciate your willingness to help!

How would I extract the entire JSON that was sent to the wf endpoint?

You need to use auto detect and also add the detect header function. This will give you access to request data raw body

2 Likes

Sounds good. Tried that. Now the “RequestData” is a “missing type” when I try to use it in a workflow. Any idea? Sorry to be a pain!

Can you share a screenshot ?

1 Like

You didn’t detect data already. Click.on detect data and send test payload to the initialize endpoint.

2 Likes

I am a fan of @Jici

1 Like

Rockstar!

This worked like a charm. I didn’t have to parse out anything. I just ran the second wf on the list of ResponseData’s Body InvoiceLines and it created all of the invoice lines and added them to the invoice header which was created in Step 1.

Might need to do a write up on this for others because it is actually easy, but not intuitive.

REALLY appreciate your help!

1 Like