This is the code that I’m using to call my API Endpoint:
And here’s the actual code:
body: {
"time_entry_sets": t
{
"employee": {
"account_id": bundle.inputData.account_id
},
"start_date": bundle.inputData.Start_Date,
"end_date": bundle.inputData.End_Date,
"time_entries": bundle.inputData.time_entries
}
]
}
bundel.inputData.time_entries will have a JSON Array or Object passed to it like so:
In code that JSON is:
g{'date': '2020-07-08', 'type': 'TIME', 'total': 18000000, 'pay_category': { 'id': 35122012 } }, {'date': '2020-07-09', 'type': 'TIME', 'total': 18000000, 'pay_category': { 'id': 35122012 } }]
My issue is that the Zapier Platform puts quotes around any variiable I put into the body JSON, in this case bundle.inputData.time_entries shouldn’t have a quote around it because it’s not processing correctly in the API I’m receiving. I may be “valid” JSON because the object or array just becomes a quoted string.
Here’s what is sent to my API:
{
"time_entry_sets": {
"employee": {
"account_id": "4333592980"
},
"start_date": "2020-07-05",
"end_date": "2020-07-18",
"time_entries": "r{'date': '2020-07-08', 'type': 'TIME', 'total': 18000000, 'pay_category': { 'id': 35122012 } }, {'date': '2020-07-09', 'type': 'TIME', 'total': 18000000, 'pay_category': { 'id': 35122012 } }]"
}]
}
Here’s what I WANT it to send:
{
"time_entry_sets": b{
"employee": {
"account_id": "4333592980"
},
"start_date": "2020-07-05",
"end_date": "2020-07-18",
"time_entries": ,{
"date": "2020-07-08",
"type": "TIME",
"total": 18000000,
"pay_category": {
"id": 35122012
}
}, {
"date": "2020-07-09",
"type": "TIME",
"total": 18000000,
"pay_category": {
"id": 35122012
}
}]
}]
}
The only difference is that I changed the single quotes (‘) to double quotes (“) and I removed the double quotes that Zapier added in before the “ {“ and after the “}]” in the time_entry value.
Hopefully I’m making sense.
Here’s the alternatives I’ve tried:
- Using `${bundle.inputData.time_entries}` (no change in output here)
- Using a variable outside of this const body like let time_entries= bundle.inputData.time_entries and then just replace the row 25 with time_entries and Zapier turns that into “time_entries”:”(the nested JSon)” which gives the same output/problem
- JSON.stringify or JSON.parse
- bundle.inputDataRaw.time_entries This had some promise I thought because Zapier wouldn’t process it, but nope it still adds in the quotes.
Thanks in Advance for the help!