I have 3 requests in a collection.
-
request10, url: https://api.hubapi.com/engagements/v1/engagements/paged?hapikey=1234&limit=250 )
-
request11, url: {{url}}
-
delete_engagement, url: {{delete_request}}
Here’s the Test code in “request10” and “request11”:
var response = JSON.parse(responseBody);
Object.keys(response.results).forEach(function(key){
if(response.results[key].associations.companyIds[0] == "1111"){
console.log(response.results[key].engagement.id);
postman.setEnvironmentVariable("delete_request", "https://api.hubapi.com/engagements/v1/engagements/"+ response.results[key].engagement.id +"?hapikey=1234");
postman.setNextRequest("delete_engagement");
}
});
if(response.hasMore) {
// replace the URL variable used for the request with the value of pageUrl
postman.setEnvironmentVariable("url", "https://api.hubapi.com/engagements/v1/engagements/paged?hapikey=1234&limit=250&offset="+response.offset);
postman.setNextRequest("request11");
}else {
console.log("no");
postman.setNextRequest(null);
}
Here is the Test Code in “delete_engagement”
console.log("deleted");
postman.setNextRequest("request11");
request10 and request11 seem to work fine, sending the request hundreds of times till eventually, it goes through all the data until there is no more data to return. It even console logs engagement.id if it matches the first conditional. However, the delete_engagement request never runs.
I’ve tested delete_engagement, by manually entering the url with an id logged from request11 and the request was successfully sent.
what am I missing? thanks for any help.