Skip to main content

Hi there, 

I’m seeing this error coming back while trying to set up a search trigger. 

Invalid API Response: - Got a result missing the "id" property

{"message": "OK", "code": 0, "data": {"list": t{"advertiser_id": xxxxxx, "advertiser_name": "xxxxxx"}]}, "request_id": "xxxxxx"}

Does anyone have any examples of how to give it an id? Perhaps using advertiser_id, or equivalent?

Here’s my current code:

const options = {
url: 'https://ads.xxxxxx.com/open_api/v1.2/oauth2/advertiser/get/',
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': `Bearer ${bundle.authData.access_token}`
},
params: {
'access_token': bundle.authData.access_token,
'app_id': process.env.CLIENT_ID,
'secret': process.env.CLIENT_SECRET
}
}

return z.request(options)
.then((response) => {
response.throwForStatus();
const results = response.json;

// You can do any parsing you need for results here before returning them

return results;
});

I’m guessing I’ll also need to have it accessing the nested data using something like results.data.list

Any help appreciated! 

Thanks

You’re on the right track. Triggers need to return a bare array of objects that contain a unique identifier explicitly called `id`.  Assuming you want to provide the ability for a user to run a workflow each time a new advertiser is added, or if you’re getting a list to populate a dynamic dropdown, then you would do something like:

 

return results.data.list.map((item)=>{

  item.id = item.advertiser_id;

  return item;}));

 

You mentioned the term “search trigger”… I’ll assume you’re using this trigger to populate a dynamic dropdown.  “Searches” in Zapier are actually a type of action rather than a type of trigger.


Hmm, I’m a bit lost then. I need a search step to get the advertiser ID for the authenticated user, but this is directing me to a trigger. 


Can you share a little more about your use case so we can get you the best answer? What are you trying to build? Describe the trigger or action, the parameters required to be mapped or selected by the user, and how this advertiser id fits into that.

If you have a trigger that starts a workflow every time a new, say, post is created by a specific advertiser, and the user needs to select an advertiser from a dropdown based on the list in that query - you’re on the right track and almost done.

If you needed to have a specific advertiser id in context to, say, build URL paths dynamically for your API endpoints then we’d want to get that into a “computed” field during auth. A challenge with that is that advertisers are in an array in your example - implying there are more than a single one that may be returned.  

With more info on what you’re trying to do we can help get you a more specific answer.


@Issues with OAuth2 
Just checking in to see if you still need help with this?