Contact API Never Returns Contacts
We are using the API get Contacts API query. Sometimes and intermittently our query returns the Contacts as expected but more often enters a state where it never returns the results. Below are logs of both cases. Our question for the failed case : "what API call do we need to make to retrieve the Contact results?"
Here is the sequence when the call returns the contacts successfully. We assume that we should call the ResultUrl from the first response to receive the list of contacts and that approach does return the data :-
Start API CALL, path: https://api.wildapricot.org/v2/accounts/<id>/contacts
response #0
Response Key: State value: Complete
Response Key: ResultId value: 0239f98f-4aa0-4071-b804-f9b9154fafaf
Response Key: InitialQuery
Response Key: ResultUrl value: https://api.wildapricot.org/v2/accounts/<id>/Contacts/?resultId=0239f98f4aa04071b804f9b9154fafaf
Response Key: Requested value: 2021-06-29T13:26:18.3611-07:00
Response Key: Processed value: 2021-06-29T13:26:55.387081-07:00
Start API CALL, path: https://api.wildapricot.org/v2/accounts/<id>/Contacts/?resultId=0239f98f4aa04071b804f9b9154fafaf
response #1
Response Key: ResultId value: 0239f98f-4aa0-4071-b804-f9b9154fafaf
Response Key: State value: Complete
Response Key: Processed value: 2021-06-29T13:26:55.387081-07:00
Response Key: Contacts
======================================
Here is the sequence when the call loops forever. The first response has state 'Waiting' and every subsequent call (forever) returns state "Processing". In this case, what API call do we need to make to retrieve the Contact results?
Start API CALL, path: https://api.wildapricot.org/v2/accounts/<id>/contacts
response #0
Response Key: ResultId value: 0239f98f-4aa0-4071-b804-f9b9154fafaf
Response Key: State value: Waiting
Response Key: InitialQuery
Response Key: Requested value: 2021-06-29T13:26:18.3611009-07:00
Response Key: ResultUrl value: https://api.wildapricot.org/v2/accounts/<id>/Contacts/?resultId=0239f98f4aa04071b804f9b9154fafaf
Start API CALL, path: https://api.wildapricot.org/v2/accounts/<id>/Contacts/?resultId=0239f98f4aa04071b804f9b9154fafaf
response #1
Response Key: ResultUrl value: https://api.wildapricot.org/v2/accounts/<id>/Contacts/?resultId=0239f98f4aa04071b804f9b9154fafaf
Response Key: ResultId value: 0239f98f-4aa0-4071-b804-f9b9154fafaf
Response Key: InitialQuery
Response Key: State value: Processing
Response Key: Requested value: 2021-06-29T13:26:18.3611-07:00
Start API CALL, path: https://api.wildapricot.org/v2/accounts/<id>/Contacts/?resultId=0239f98f4aa04071b804f9b9154fafaf
response #2
Response Key: State value: Processing
Response Key: InitialQuery
Response Key: ResultId value: 0239f98f-4aa0-4071-b804-f9b9154fafaf
Response Key: ResultUrl value: https://api.wildapricot.org/v2/accounts/<id>/Contacts/?resultId=0239f98f4aa04071b804f9b9154fafaf
Response Key: Requested value: 2021-06-29T13:26:18.3611-07:00
Start API CALL, path: https://api.wildapricot.org/v2/accounts/<id>/Contacts/?resultId=0239f98f4aa04071b804f9b9154fafaf
response #3
Response Key: InitialQuery
Response Key: Requested value: 2021-06-29T13:26:18.3611-07:00
Response Key: ResultUrl value: https://api.wildapricot.org/v2/accounts/<id>/Contacts/?resultId=0239f98f4aa04071b804f9b9154fafaf
Response Key: ResultId value: 0239f98f-4aa0-4071-b804-f9b9154fafaf
Response Key: State value: Processing
...
...
...
![](https://secure.gravatar.com/avatar/04a661ee8ee0722f585c62afa6ed18a5?size=40&default=https%3A%2F%2Fassets.uvcdn.com%2Fpkg%2Fadmin%2Ficons%2Fuser_70-6bcf9e08938533adb9bac95c3e487cb2a6d4a32f890ca6fdc82e3072e0ea0368.png)
There are 2 options:
1. If you need data immediately, then you may add a parameter $async=false to the initial query. With this flag API returns a list immediately. If your number of contacts is below 500 it is a reasonable option.
2 Another option is to do exactly what you do, but wait for several seconds between API calls.
No matter what option you prefer, I’d recommend using $select parameter to read only the fields you actually need. It will significantly improve performance.
Here is an example:
GET https://api.wildapricot.com/v2.2/Accounts/183112/Contacts/?$async=false&$select='First name’,‘Last name’,‘Renewal due’
-
wa commented
How big is the expected dataset? How long do you wait between polling attempts? If the dataset is large it can take the web service some time to prepare the results. I've seen 20-30 seconds when requesting a complete list of 2400 contacts. If you are returning more than a few hundred objects, you may want to use $skip and $top to page through the results. The query is run only once and the results cached at the server based on the resultId.
In my application I wrote a simple front-end that exposes "run query" and "get next" methods (analogous to SQL query and resultset) that hides all the polling and paging from the client code.
-
David Murphy commented
Thanks, Dmitry - do you know if there is documentation somewhere that describes the states coming back from the WA API? Specifically how to handle each state. I never saw such doc but I assume it exists somewhere...