Hi!
I’m trying to create a new Action for our app. I have created simple actions and triggers with success, but can’t create this one with ‘Line Items’ support.
This is the JSON required by our API. This is a simplified example:
{
"gross": "100",
"total": "121",
"name": "Adobe",
"lines": [
{
"sku": "",
"descr": "Corsair H60 120mm GAMING LGA1200",
"quantity": "1",
"price": "100.00000"
}
]
}
In the Input Designer, I created the generic fields and the line items fields:
![](https://uploads-us-west-2.insided.com/zapier-ca/attachment/da3b3dd2-5537-42cf-9245-30cfdb76fd49.png)
In the API configuration tab, I have to Switch to ‘Code Mode’ because, as said, our API requires the json to come in the ‘data’ param, so I did this:
const options = {
url: 'https://myapp.cloud/api/expenses',
method: 'POST',
headers: {
'apikey': bundle.authData.apikey
},
params: {
'data': '{"name":"'+bundle.inputData.name+
'","gross":"'+bundle.inputData.gross+
'","total":"'+bundle.inputData.total+
'","lines":"'+bundle.inputData.lines+'"}'
}
}
Now if I “create a zap with this action’, I have tried with a single item/line…
![](https://uploads-us-west-2.insided.com/zapier-ca/attachment/4b7631cf-4cf2-4745-bf6c-ae6d36b26a40.png)
...and using comma separated items like this:
![](https://uploads-us-west-2.insided.com/zapier-ca/attachment/eb63658c-d310-4262-9a4f-b2ad4693153a.png)
...but it is not working as expected. I think the problem is in the “Code Mode” section, that requires the lines to be sent in other way.
My API log shows this as the received request:
JSON: {"name":"Peter","gross":"100","total":"121","lines":"[object Object]"}
How can I prepare the request to send the line items to my api server, inside a ‘data’ parameter?
Thanks!