Add an Array of Objects to JSON for API POST Call

So I need to make a POST call to my Cloud Functions. I need to pass. SON with list of LineItems like to the body of the call as shown below.

  "lineItems": [
      "amount": 50.0,
      "taxableAmount": 40.0,
      "taxable": true,
      "discountAmount": 5.0
      "amount": 30.0,
      "taxableAmount": 25.0,
      "taxable": false,
      "discountAmount": 2.0
  "deposit": {
    "documentId": "D123",
    "companyId": "C456",
    "type": "PERCENTAGE",
    "value": 10.0
  "discount": {
    "id": "DIS789",
    "companyId": "C456",
    "name": "Discount 1",
    "type": "AMOUNT",
    "value": 5.0
  "taxRate": 8.5,
  "shippingCost": 7.0

If I copy the above and past into API connector, it works fine. However I need to dynamically pass in the value so I change it to

  "lineItems": <lineitems>,
  "deposit": {
    "documentId": <depositId>,
    "companyId": <companyId>,
    "type": <depositType>,
    "value": <depositValue>
  "discount": {
    "id": <discountId>,
    "companyId": <companyId>,
    "name": <discountName>,
    "type": <discountType>,
    "value": <discountValue>
  "taxRate": <taxRate>,
  "shippingCost": <shippingCost>

And the calls are failing because of JSON SyntaxError.

I have tried to make the array as "lineItems":[ <lineitems>],

Anyone have an example of how you pass dynamic sized array of objects to a POST body?

I don’t think the issue is formatting the JSON items, but letting the API connector know that this field is an array.

You will need to investigate a little bit more. Can you inspect the output when you run the WF? for example, if you have a missing value, let’s say discountAmount, this will be empty. This is not valid and probably you should replace this by null (or remove the line). Also, keep [ ] in API connector if you don’t put it in dynamic field

Can you add screenshot of your API connector configuration and also of the dynamic field in workflow?

You can also send the request to to inspect it.

Thank you for the pointers, but it does appear that the WF is populating the payload correctly. It appears that the API connector is not formating the Call body as proper JSON.

Here is the log

And here is the API Connector setup

if you look at your debug expression, you will see that the json is not correct and exactly what I said: you have empty value. This is not valid in JSON so you need to check if the value is “available” and if not, replace it by null.
So in your screenshot, in amout, the expression should be This lineitem's discountedprice is not empty:format as text yes= This lineitem's discountedPrice, no = null
Same thing applied for discount amount
You probably need to do the same thing for taxableamount if this could be empty

Also, I guess that some of your JSON in API connector have missing double quotes " like for name, type and all ID…

Based on the ample you provide

I have never successfully passed a Json array in an api call admittedly. Maybe I’m using the wrong quotes? :man_shrugging:

Nothing seems to work for such a simple usecase. At the verge of returning to code.

Did you copy paste the json I show you? Did you add empty field validation? This is all you need to get it work