Skip to main content

Hi all ! 👋

The Zapier community already helped me a lot with my Zaps ! 🙌

Hope you will be able to help me on that one also 🤗

Today i’m facing a problem interacting with another API with webhooks and Curl commands.

I’m sending my GET request with webhooks as set below :

 

The problem I’m facing is that I don’t get the full answer from the server.

What ever the request I only get the1st lines of the full response.

For example with this same command in the swagger UI (provided by the API), I get this answer :

n
{
"id": "*****************",
"smartlockId": *****************,
"authId": *****************,
"type": 0,
"name": "Nuki Web",
"enabled": true,
"remoteAllowed": true,
"lockCount": 0,
"lastActiveDate": "2022-08-17T17:54:46.000Z",
"creationDate": "2022-08-17T17:54:46.000Z",
"updateDate": "2022-12-20T02:27:35.495Z"
},
{
"id": "*****************",
"smartlockId": *****************,
"authId": *****************,
"type": 0,
"name": "USER",
"enabled": true,
"remoteAllowed": true,
"lockCount": 4,
"lastActiveDate": "2022-09-16T09:51:19.000Z",
"creationDate": "2021-01-01T00:00:43.000Z",
"updateDate": "2022-12-20T02:27:36.648Z"
},
{
"id": "*****************",
"smartlockId": *****************,
"authId": *****************,
"type": 3,
"name": "Nuki Keypad",
"enabled": true,
"remoteAllowed": false,
"lockCount": 775,
"lastActiveDate": "2022-12-19T19:15:53.000Z",
"creationDate": "2022-08-17T17:53:26.000Z",
"updateDate": "2022-12-20T02:27:36.655Z"
},

GOES ON ....

]

 

But when i’m using WebhHooks by zapier I only get this first ID :

id
*************
smartlockId
*************
authId
*************
type
0
name
Nuki Web
enabled
true
remoteAllowed
true
lockCount
0
lastActiveDate
2022-08-01T15:35:44.000Z
creationDate
2022-08-01T15:35:44.000Z
updateDate
2022-12-19T14:17:36.841Z

If you guys have any idea why I can’t guet the full response ?

 

Thank you in advance for your help !

 

Bests,

Raoni

Hi @Raoni 

There is a chance that Zapier would be engaging in a loop…  which would be hard to tell in the set up. When you return an array of objects Zapier most commonly loops each remaining step (as is the case from a code block -- though its not apparent that this will happen) or just returns the first object (as is the case for most search actions). 

If you want greater control over what is returned, i’d suggest using a javascript code block and making a fetch request. 

 

let response = await fetch(URL, {
method: "GET",
headers: {
Authorization: 'Bearer YOUR_TOKEN',
Accept: 'application/json'
}
})


let data = await response.json()


return {data}

 


Hi @GetUWired,

Thank you for your fast answer.

If you want greater control over what is returned, i’d suggest using a javascript code block and making a fetch request. 

 

Do you mean I should use a code step or simply add this javascript code in Query String Params ?

Sorry if the questions seems dumb but i’m not very used to JS.

 

Thanks again 🙌

 


Short message just to thanks you @GetUWired !

Your solution using a code step and the JS code worked great !

Just took me some time to figure it out but I keep learning. 😅

Thanks again for the help 🙌


@Raoni Glad to hear you were able to figure it out!


 Hi, 👋

I’m unfortunately back beacause I can’t figure out how to get the correspondig datas from the fetch request.

This is how i get the datas from the fetch request :

data

  • 1

id

********************a6e9

smartlockId

**********316

authId

*****648

type

0

name

Nuki Web

enabled

true

remoteAllowed

true

lockCount

0

lastActiveDate

2022-08-17T17:54:46.000Z

creationDate

2022-08-17T17:54:46.000Z

updateDate

2022-12-30T02:37:36.056Z

  • 2

id

********************a70a

smartlockId

**********9316

authId

*****645

type

0

name

Moisan

enabled

true

remoteAllowed

true

lockCount

4

lastActiveDate

2022-09-16T09:51:19.000Z

creationDate

2021-01-01T00:00:43.000Z

updateDate

2022-12-30T02:37:37.167Z

  • 3

id

********************a70d

smartlockId

**********9316

authId

*****647

type

3

name

Nuki Keypad

enabled

true

remoteAllowed

false

lockCount

846

lastActiveDate

2022-12-29T22:22:22.000Z

creationDate

2022-08-17T17:53:26.000Z

updateDate

2022-12-30T02:37:37.409Z

  • 4

id

********************a74d

smartlockId

**********9316

authId

*****

code

*****22

type

13

name

Code d'entrée

enabled

true

remoteAllowed

false

lockCount

324

lastActiveDate

2022-12-29T14:25:56.000Z

creationDate

2022-08-17T17:53:44.000Z

updateDate

2022-12-30T02:37:41.614Z

  • 5

id

********************1dc5

smartlockId

**********9316

accountUserId

*****609

authId

*****654

type

0

name

19064155 #3

enabled

true

remoteAllowed

false

lockCount

0

allowedFromDate

2022-08-18T13:00:00.000Z

allowedUntilDate

2022-08-25T09:00:00.000Z

allowedWeekDays

127

allowedFromTime

0

allowedUntilTime

0

lastActiveDate

2022-08-18T07:48:24.000Z

creationDate

2022-08-18T07:48:24.000Z

updateDate

2022-12-30T02:37:36.117Z

 

I want to look for a “name” value (IE here “Nuki Web”) and recover the corresponding data for the “authid” value (which in this case would be “*****648”).

I tried using a “fromatter” step, “Line Itemizer” step, “loop” step but its not working because the data i get from the JS code always stays grouped per value items separated with comas like this :

name : Nuki Web, Moisan, Nuki key pad, …

authID : *******, *******, *******, …

 

I would like to be able to use it in nexts steps in a way where it’s grouped “per user” not “per value”…

I also tried using a JS code step like this to look up for the data :

 

But It’s not helping ☹️

 

If you guys know how I could do it, I would really apreciate the help.

 

Thanks. 

 


@Raoni

it looks like the API call is returning an array of objects. You can use a filter statement to narrow down the results based off a specific value 

Here is a related article: 

 

But your structure is a little more complicated. You should be able to do something like the below in place of the return {data} line in your existing code
 

let person = data.filter(obj => obj.name == "Nuki Web")

return {person}

 
 


Hi @GetUWired,

Thank you again for your help.

I was able to solve it myself with the JS code I mentioned earlier. It was a rookie mistake on the "find" input with uppercase and lowercase... 😑

 

 My message were moderated and I thought It wouldn't be published otherwise I would have came back to post the "solution".

 

Thank you again.

Bests,

 

Raoni