Skip to main content

Hello, I have a search step that only returns the values of the first object. The output of the search step if done using an actual API call would be:

output: [{foo1: bar}, {foo2: bar}, etc]

Doing this call search using a JS fetch wouldn’t really be possible as it requires a cookie, hence why using Zapier for the OAuth is really useful for automation. However Zapier only outputs the information of the first object in the array, and I cannot find a way to be able to loop through this step as there is no way of referencing it without referencing an actual preview which will not loop at all.

I am aware that if the creator of the integration was to have it as an array of one object which contains all the results it would work, like:

/case: {{foo1: bar}, {foo2: bar}, etc}]

But this isn’t possible to request for as it would potentially break other functionality. Is it literally not possible? Trying to have a code step doesn’t really work as I can’t specify an input without referencing the search, and that will only see it as one item. Are there any ways around this, perhaps using tables?

Any help would be appreciated!

What search step are you using?

Depending on the search step and the integration, it may be possible to do what you're looking for within the integration. Otherwise, it may be possible using a raw API call using a Webhooks step.


Hi ​@bedeaw 

I’ve seen this behavior before and it usually requires using a Code step, which supports inputs, to make the API request, then you can handle the response however you’d like.

https://zapier.com/apps/code/integrations#help

 

 


Hi ​@bedeaw 

I’ve seen this behavior before and it usually requires using a Code step, which supports inputs, to make the API request, then you can handle the response however you’d like.

https://zapier.com/apps/code/integrations#help

 

 

Thanks for the reply. Unfortunately I can’t do this on a consistent basis. I have tried doing this and it does work, however, the integration I am using requires a cookie for an API call, which is generated from my OAuth user, and Zapier has no way of getting the `authorization` cookie from my current session. So when I have done this, I have passed in a hard-coded cookie into a JS fetch request.

For one off instances this works perfectly, and is exactly how I want to return my information, however due to the cookie required in the request headers, it isn’t a permanent solution.

Is there any other way around this that you are aware of?


What search step are you using?

Depending on the search step and the integration, it may be possible to do what you're looking for within the integration. Otherwise, it may be possible using a raw API call using a Webhooks step.

Hello, thanks for replying. I am using a private integration, I am aware that a search step for google sheets has a return multi-line or something like that, which will allow multiple returns. Is that what you are suggesting?

I think the raw API call won’t work as the API call requires a `authorization` cookie, so I can hard code it, but in terms of repeatability and automation, it isn’t a viable option.

I have suggested to the owner of the integration, a true/false flag for return multi line item, which would then on true return an array with one object, filled with objects, which would work I believe. And then false would return the previous functionality. However the owner wasn’t keen on changing and said it was possible without any explanation.


@bedeaw 

What app API endpoint are you trying to user? (link to documentation)


Hello, I have a search step that only returns the values of the first object. The output of the search step if done using an actual API call would be:

output: [{foo1: bar}, {foo2: bar}, etc]

Doing this call search using a JS fetch wouldn’t really be possible as it requires a cookie, hence why using Zapier for the OAuth is really useful for automation. However Zapier only outputs the information of the first object in the array, and I cannot find a way to be able to loop through this step as there is no way of referencing it without referencing an actual preview which will not loop at all.

I am aware that if the creator of the integration was to have it as an array of one object which contains all the results it would work, like:

>case: {{foo1: bar}, {foo2: bar}, etc}]

But this isn’t possible to request for as it would potentially break other functionality. Is it literally not possible? Trying to have a code step doesn’t really work as I can’t specify an input without referencing the search, and WOPET that will only see it as one item. Are there any ways around this, perhaps using tables?

Any help would be appreciated!

Zapier only outputs the first object from an array unless the integration is designed to return a list. Since that's not the case here, your best workaround is to use a Code step with bundle.rawRequest.responseContent if available, or use a Webhooks step to manually replicate the API call with the cookie. Alternatively, send the full array to Zapier Tables or Google Sheets and trigger a Zap for each row. Looping directly isn't possible unless the integration returns a properly structured array marked as a list.


If you are facing the issue of expiration of cookie then, you can add a login step in your zap, where you can make an api post request using the login credentials to the desired app login endpoint, and you will receive the cookie in response, you can use the cooke in your js code step.

This way when ever your zap runs, it will get a new cookie token from the login step and use that in the following js step.


Reply