Values stripped from JSON on API call

Having a very strange issue that I just cannot debug, I’ve tried everything I can think of.

I’m using T1 CSV uploader - list of JSON texts gets pased to an endpoint and then run through some workflows.

The JSON is being produced correctly from the uploader and appears to be hitting the endpoint in the right format:

But as an example, the highlighted field/value is being stripped out:

It’s not present at all in this step:

And you can see here, it’s showing as blank:

When adding a debug log, I just get an empty thing separated by commas:

image

I’ve checked:

privacy rules
CSV format
Value in the csv
Modify types
Running with/without authentication

Any ideas?

From what I understand, you are sending the JSON to API workflow? Using api connector? How did you set your backend WF? Can you share the whole json sent? API Connector settings? Action that encode the JSON?
Also, the encoding seem wrong to me because the options are in a string instead of array of string…

That’s correct.

I’ll refer you to this thread, in which I followed the advice of another user to get this set up.

Here is a snippet of the JSON being sent from the T1 CSV uploader (where the values are showing correctly in debug):

[{“Manufacturer”:“BMW”,“Model”:“C-Class”,“Variant”:“Hybrid”,“Finance Provider”:“Novuna”,“CAP ID”:5746,“CAP Code”:“CAP2198”,“Trim”:“["Standard", "Dynamic"]”,“Options”:“["Alloy Wheels", "Built-in Sat Nav"]”,“Colours”:“["Black", "White", "Red"]”,“Initial Term”:3,“Contract Length”:48,“Annual Mileage”:10000,“Upfront Cost”:9191,“Monthly Cost”:717,“hasBreakdown?”:“Yes”,“Breakdown Cover Cost”:17,“includesRoadTax?”:“No”,“Road Tax Cost”:95,“hasMaintenance?”:“Yes”,“Maintenance Cost (Monthly)”:463,“Fuel Type”:“Petrol”,“CO2 Emissions”:214,“Engine Power”:324,“Fuel Economy”:56.5,“EV Connector Type”:“Type 2”,“EV Battery Capacity”:79,“Range”:172,“Transmission”:“Manual”,“Processing fee”:99,“Delivery cost”:0,“Important info”:“No info”,“Drivebase Customer”:“Company Ltd”,“Commission Value”:300},

Here’s the API settings:

![image|503x500](upload://zpSIfPkhPNUcis9yRWVPJOLJDMA.png

Action that sends the JSON:

Debug in that screenshot pulls value correctly from JSON.

Can you provide the full json sent (put them between ``` quotes so we can read it correctly in forum) and how did you set the API endpoint in backend workflow? using detect data? manually entered values?

I used detect data.

Here is the link to the pastebin:

I did a test on my side an didn’t get any issue. What I suggest is:
A) Detect your payload again in API workflow (send the same request from pastebin using postman for example). Check field mapping after that.
B) Validate the json sent from API connector using a requestbin.com (or similar tool) to check if the json have the same structue when sent. Also, be sure to validate content-type header.

Are you sending the request after to another workflow (schedule on a list)? If yes, please share what you have set for this workflow

1 Like

Thanks @Jici - detecting the data using the JSON I put into Pastebin has resolved the original issue, but it’s unfortunately created a new one with the “lists”.

For example:

“Colours”:“["Black", "White", "Red"]”

In the debug record, it shows exactly the same as it did before I did the new “detect data”, but the workflow produced errors and wouldn’t accept what I’d previously done:

image

I literally just copied and pasted the JSON from pastebin - clearly I’m missing something but don’t know what.

Edit: It’s actually all the lists that are now having an issue.

Don’t worry, I sorted it in the end with a “find and replace” to get rid of [ and " and then did “split by”.

Not sure if that’s the best way, but it works.

Thanks again for the assist.

The payload I got from your pastebin was a string for colours

    "Colours": "[\"Black\", \"White\", \"Red\"]",

You can see that the array is escaped and encoded into double quotes. This mean this is a string, not an array of colours.

More than that, when there’s only one colours, this is returned as a string value without any square brackets. This could cause issue if this was in JSON. So better to keep it as string and use regex or find and replace with split by like you do.

Thanks.

The T1 uploader instructs me to format the fields inside the CSV as a JSON array, which is what I’ve done - I’m guessing that’s why it’s doing this?

Should I just put them in separated by commas - it would actually be better if I don’t have to do this, as it makes it more difficult for customers to format the file properly.

image

I don’t know how T1 work so it’s hard for me to help about formatting this correctly. The best would be to always return an array of string like you have in your screenshot, but I guess this may be something not handled by T1.