How to pass leadId from one url to another?

[
{
// Request to API endpoint.
“url”: “/accounts/{{parameters.accountId}}/custom-feeds/{{parameters.customFeed}}/leads”, // Relative to base URL
“method”: “GET”,
“headers”: { },
“qs”: {
“start_date”: “{{parameters.startDate}}”,
“end_date”: “{{parameters.endDate}}”
},

    // Response handling
    "response": {
    "iterate": "{{body.data}}",
    "output": {
    "leadId": "{{item.id}}"
    }

}
},
{
“url”: “/accounts/{{parameters.accountId}}/leads/{{leadId}}/visits”,
“method”: “GET”,
“headers”: { },
“qs”: {
“start_date”: “{{parameters.startDate}}”,
“end_date”: “{{parameters.endDate}}”
},

 // Response handling
 "response": {
     "iterate": "{{body.data}}",             // Iterates "data" array from API response to split it into individual items.
     //"output": "{{transformLeadData()}}",
     "output":{
         "Lead Id": "{{leadId}}",
         "Visit": "{{item}}"
     },
     "limit": "{{parameters.limit}}" // Limits number of output bundles as requested by user (even if API returns more items).
 }
}

]
on that above code from my first url i get the leadId here i want to pass leadId dynamically in the second url but it show me error and in the second url leadId not found.

1 Like

Hi @Pritam_Koyari ,
You can store the item.id in a temporary variable instead of using output, and then call it in the next URL using temp.leadId.

example
Instead of this:-

// Response handling
“response”: {
“iterate”: “{{body.data}}”,
“output”: {
“leadId”: “{{item.id}}”
}
}

Use this:-
// Response handling
“response”: {
“iterate”: “{{body.data}}”,
“temp”: {
“leadId”: “{{item.id}}”
}
}

Then in the next request:

“url”: “/accounts/{{parameters.accountId}}/leads/{{temp.leadId}}/visits”

Please try this approach and let us know your feedback. Thanks!

Best regards,
Msquare Automation
Platinum Partner of Make
@Msquare_Automation

3 Likes

It also same issue can you suggest me any other solution?

Hi @Pritam_Koyari ,

Could you please share the images showing how you’re adding the temp variable, so we can guide you accordingly?

Best regards,
Msquare Automation
Platinum Partner of Make
@Msquare_Automation

2 Likes