First of all I am not asking for API-specific help before anyone implies that. I am having a strange issue while consulting Active Campaign's API.
There's a specific endpoint I am using that is the GET contacts
endpoint. Normally I don't have any issues with this endpoint, but in a specific case scenario where I use the segmentid
get parameter I am having inconsistencies with the information.
I am using two ways to get to the API. One of them is Postman and the other one is my code using the Guzzle http client for php.
When I consult in Postman, on the first result I get this strange variable that says waiting => true
and my contacts
array is empty. When I consult the exact same endpoint again, the variable waiting
is gone and I get the corresponding contacts array filled with the corresponding results. So, basically the idea is that if I do it a second time I get a result.
Now, on the other hand, with my code I am doing the exact same endpoint request and I tried repeating the request twice and both times I get the exact same result with waiting => true
. I even tried the following:
foreach($segments as $index => $segment) {
$segments[$index]['contacts'] = $this->ac->get_contacts(array(), $segment['id'], 'desc', 1, 30, 0);
while($segments[$index]['contacts']->meta->waiting == true) {
usleep(250000);
$segments[$index]['contacts'] = $this->ac->get_contacts(array(), $segment['id'], 'desc', 1, 30, 0);
}
}
But even like this it stays requesting forever and the result never changes and I end up getting a 504 error.
Now my main question is: How is it possible that the result of the same endpoint varies between those two ways of getting the information, and am I missing some parameter or what do I need in order to replicate the same behavior as Postman in order to obtain the information?
The Api-Token is the same, the endpoint is the same.