Skip to main content

 

Hello!

So I am very new at code and API calls so I’m not sure what I’m misunderstanding exactly!:)

I am trying to use the PayPal API to generate automated invoices, using our internal system to pass the item data dynamically to the POST request to create an invoice .For more context, clients will likely have 2-4 items on their invoice, so I am looking for a way in which we check those off on our internal system (monday.com), then that client’s data and items are passed to this Zap, in which an array is created with the items purchased and a custom invoice is generated.

To do that, I’ve been using various Utilities steps to transform the item data from our internal workflow into a JSON object that can be dynamically added into the body of the invoice. For reference the items object should look like this:  

 "items": "
{
"name": "Test Item 1",
"quantity": "1",
"unit_amount": {
"currency_code": "USD",
"value": "400.00"
},
"unit_of_measure": "QUANTITY"
},
{
"name": "Test Item 2",
"quantity": "1",
"unit_amount": {
"currency_code": "USD",
"value": "100.00"
},
"unit_of_measure": "QUANTITY"
}
]

I was able to using line-itemizer and line-item to text to transform my list of items + prices:

Item 1 - 400.00

Item 2 - 100.00

to get a desired output that looks like this: 

However, when I input this as a dynamic value in the raw json body like this:

I get this error:  

 

I understand that the dynamic data needs to be in line-item/array form, not just string, but I’m hitting a wall on how to achieve this as it is a nested JSON array. All I’ve found for how to create json/line-item arrays in Zapier hasn’t quite helped with a nested object like this- or at least I’m not understanding how to apply those methods to this case. I even tried validating the JSON, but it was coming back invalid - even though the structure was provided by the PayPal public API and working otherwise (without the dynamic data).

Any assistance on how to create this nested array in a previous step to be able to input it dynamically into the raw json of the POST request? Once again, very amateur at this so I may be missing something extremely basic here - but would love any insight! Also happy to answer any clarifying questions as I may not be explaining the situation clearly either. Thank you in advance!