Skip to main content

I’m creating a Zap to post a field that is coming in from Google Sheets as a comma-separated string, to my app’s API that expects an array of strings.

In Zapier Developer, I test it by keying in a comma-separated string and it works fine with a payload like this:

 

But in the Zap, I keep getting error: The app returned "activityTypesWillingToDo must be an array of strings".

I’ve tried Transforming from String to Line-Item, I’ve tried javascript to turn it into an array:

const { lineItemEasy, } = inputData;

const lineItemEasyArray = lineItemEasy.split(',');

output = p{ lineItemEasyArray, }];

And I’ve tried actually hard-coding the array of strings into the input field of my Action.

Please help!

 

What API are you using? 

What does your code look like or the input fields? 

If you have the items in an input field called “activityTypes” you can use the following code to check if the value is an array and if not split it into one. 

 

let lineItems = I];

if (Array.isArray(bundle.inputData.activityTypes))
lineItems = inputData.activityTypes;
else
lineItems = bundle.inputData.activityTypes.split(",");

 


@GetUWired The API I’m using is in my company’s commercial software app documented here.

I currently don’t have any code on the input field itself.

The code you gave, would that go in a  Run Javascript step in the Zap? Or would that go in the back end integration setup (which I’m currently not using custom code there)?


It can go into the backend integration. And it is assuming the input field key for “activityTypesWillingToDo” is just activityTypes.

The input field can also be configured to allow multiple multiples. https://platform.zapier.com/docs/input-designer#allows-multiples

I hope that helps !


Hi @jeffernst were you able to get this resolved? Let us know how it goes!


@Matt_Boyden Yes, thank you @GetUWired , that did the trick.

Jeff