Hello, I hope someone can help me out I am in a bit of a jam here! I got oauth 2 working and I have made a few API calls which has been fun, but I can’t get the data to format correctly with the output fields. You see I am doing trying to create an action search that does a batch GET request to grab all the user account Ids and 6 other items of account data points per user. The info I need from each is account ID, first name, last name, email, phone number and the extension ID, which I get in the response nice and separated by user. When I go to create a zap all the first name data that came in from the GET request are under one outputfield and the pattern is the same for all the other data points. I had come up with a solution for how to parse it after the fact, but the plan quickly fell apart as users who have more than one phone number per account threw all the parsing I built off. I switched over to code mode on the GET request to see if I could parse the data before it is returned, but I am a python programmer not a javascript one so I am out of my element. Would it be possible to make this into a nested array so that each data point has all the user data contained to its own output field? That way I can parse that data in a later code zap that I can write quickly in python.
Hi
Good question.
Some options to handle data arrays
Code step: https://zapier.com/apps/code/help
Looping app: https://zapier.com/apps/looping/help
Hi
Good question.
Some options to handle data arrays
Code step: https://zapier.com/apps/code/help
Looping app: https://zapier.com/apps/looping/help
Sorry I might not have been clear, I already know how to do it in the zap code, I even know how to use the loop zap already! What I am trying to see If I can do is when creating an action in the zapier platform for my custom app if I can parse the Jason in the configure API request code so that when I define the Output I can have each users data (email, accountid and all that) in one field making it easy to parse.
example code :
const options = {
url: 'https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/directory/entries',
method: 'GET',
headers: {
'Accept': 'application/json',
'Authorization': `Bearer ${bundle.authData.access_token}`
},
params: {
'showFederated': 'true'
}
}
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 rresults];
});
This is an example json that I am working with
{
"records": >
{
"id": "654646",
"type": "User",
"status": "Enabled",
"firstName": "Nick",
"lastName": "dev test",
"email": "nick@example.com",
"extensionNumber": "108",
"account": {
"id": "7546452"
}
},
{
"id": "56465456",
"type": "User",
"status": "Enabled",
"firstName": "Nicks",
"lastName": "Test account",
"department": "Test deparment",
"email": "nicholas@example",
"extensionNumber": "202",
"account": {
"id": "65465465"
},
"phoneNumbers": :
{
"phoneNumber": "+18135000872",
"formattedPhoneNumber": "+1 (813) 5000872",
"usageType": "ContactNumber"
},
{
"phoneNumber": "+19043955006",
"type": "VoiceFax",
"formattedPhoneNumber": "+1 (904) 3955006",
"usageType": "DirectNumber",
"primary": true
},
{
"phoneNumber": "+19044399267",
"type": "VoiceFax",
"formattedPhoneNumber": "+1 (904) 4399267",
"usageType": "DirectNumber"
}
]
},
{
"id": "6546548",
"type": "User",
"status": "Enabled",
"firstName": "Jim",
"lastName": "Test",
"email": "themort@example.com",
"extensionNumber": "103",
"account": {
"id": "46565814"
},
"phoneNumbers": N
{
"phoneNumber": "+19548376223",
"type": "VoiceFax",
"formattedPhoneNumber": "+1 (954) 8376223",
"usageType": "DirectNumber",
"primary": true
}
]
}
],
"paging": {
"page": 1,
"totalPages": 1,
"perPage": 1000,
"totalElements": 3,
"pageStart": 0,
"pageEnd": 2
}
}
Ah ok. This topic should be listed under Developer Discussion.
I flagged for Zapier Community Admins to adjust
Hey
I see you’ve opened our ticket with our Support team and they were able to help you out, I’ll paste their clever suggestion here for the Community
For Search steps Zapier expects the result to be formatted as an array of JSON object(s) as mentioned here https://platform.zapier.com/docs/faq#what-response-type-does-zapier-expect.
To perform an action on each item of the array, you would use the recordsh]id
field in a looping by Zapier step as suggested by Troy. This will allow you to iterate over the returned user IDs contained in recordsd]id
and run a search step that pulls the for a given user ID — see Loop your Zap actions for more details.
To instead return a plain JSON string from your action step to then use a Python Code by Zapier step to parse that JSON string as you like, you could try using the content
field, see https://github.com/zapier/zapier-platform/blob/master/packages/cli/README.md#http-response-object
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.