0

I recently found that calling https://api.xero.com/api.xro/2.0/contacts returns results but does not populate the ContactPersons field, and it's always empty.

However, calling the API with the ids query parameter populated, then it does populate the ContactPersons property correctly.

This does create an awkward situation, where on initial calls to the contacts, I need to loop though all the results then individually call the contacts again while passing the ids query parameter for each just to be able to extract the ContactPersons details.

Is there some other way of returning all the contacts while also returning the ContactPersons for those contacts?

I tried using the searchTerm query param to force return the result, hoping that it would then populate. However this did not work.

I also tried using the searchTerm to only return the ContactID then having my loop to extract the details for each contact, however ContactID does not seems to be a valid searchTerm so this also did not work.

I'm currently making use of the summaryOnly and setting it to true. Then still looping though the results, and calling the API again but with the ids query parameter to get the results I require.

PS: I am luckily also making use of the If-Modified-Since in all of this. So would only really be a problem if it was the first time.

One thing I did not verify was that if changes to the ContactPersons would trigger the If-Modified-Since to include the contact again. Might need to test and verify when it happens.

1 Answers1

0

We recommend that you use paging in your scenario.

To utilise paging, append a page parameter to the URL e.g. ?page=1. If there are 100 records in the response you will need to check if there is any more data by fetching the next page e.g ?page=2 and continuing this process until no more results are returned.

By using paging all the elements in each individual contact are returned in the response which avoids the need to retrieve each individual contact to get all the details (GET Contacts without paging only returns a subset of elements)

sallyhornet
  • 364
  • 2