Skip to main content

Hi,

 

So I have an API call that I make to look to see who is scheduled. 

But instead of it it returning me the actual data, it returns me IDs.

 

So when I really want to get

 

Who: John

Start Time: 09:00

End Time: 12:00

 

Who: Fred

Start Time: 12:00

End Time: 13:00

etc

 

Instead I get

 

Who: 12355

Start Time: 09:00

End Time: 12:00

 

 

Who: 12356

Start Time: 12:00

End Time: 13:00

etc

 

Needless to say, to me, 12355 is meaningless to me as a human

 

Thankfully I can call another API call that contains a reference of people and similar for places.

 

So

 

12355 : John

12356: Fred

etc

 

My questions is, how can I smash these together in Zapier?

 

As what I want is the first thing, that tells me in English, who the person is!

 

 

 

I’ve made the zap work, by manually hard coding the data in the second API call myself using a lookup table.

But this fails whenever we get new people added to the list. 

 

I thought maybe I could dynamically populate the lookup table from the API, but I dont think this is possible?

 

The other work around would be to send an API call to the second, API using the ID from the first, but this feels like an overkill, and with me potentially sending loads of calls, to something that could be done in a single one, then filtered somehow?

 

 

 

 

 

You would need to use code to match everything back up efficiently. It’s hard to offer more specific advice without seeing the data structure returned from the API calls. 

Are you making these calls with Zapier’s webhook actions or building something more custom in developer.zapier.com? 
 


You would need to use code to match everything back up efficiently. It’s hard to offer more specific advice without seeing the data structure returned from the API calls. 

Are you making these calls with Zapier’s webhook actions or building something more custom in developer.zapier.com? 
 

Hi

I’m using webhook to bring in the items.

The data structure really isn’t that complicated, as below.

 

data:
1:
customerId: 1067303
startDateTime: 2022-01-19T09:00
endDateTime: 2022-01-19T22:00


2:
customerId: 1067304
startDateTime: 2022-01-19T12:00
endDateTime: 2022-01-19T22:00


 

and

 

data:
1:
id: 1067303
firstName: Fred
lastName: Johnson

2:
id: 1067304
firstName: John
lastName: Fredson




 


Hi All

 

I ended up going with the second method:

 

Taking the employee ID from the first call, and calling a second API call using that as a query to fetch the full name.

 

I’m sad that is uses so many API calls and loops, but at least it’s future proof!


Since it isn’t likely that a name would have a comma in it you can use a code block (javascript) like the below. This is assuming you need a similar structured output. 

 

let customerIds = inputData.customerIds.split(",");
let ids = inputData.ids.split(",");
let first_names = inputData.fnames.split(",");
let last_names = inputData.lnames.split(",");
let startTimes = inputData.startTimes.split(",");
let endTimes = inputData.endTimes.split(",");

output = {
matchedRecords: d]
}
for (var i=0;i<ids.length;i++) {
if (customerIdsri] == ids i]) {
output.matchedRecords.push({
id: ids i],
first_name: first_namesai],
last_name: last_namesai],
startTime: startTimesii],
endTime: endTimesii]
})
}
}