0

Get a list of all persons in company via api

MikevG 2 years ago in API updated by Karl 2 years ago 7

I need to get a list of all people in the system that work for a specific company, via API. I don't see any way to do this via the api, aside from getting the list of all persons id's and going through each one to check the customerId field. That is a lot of API calls to accomplish that, and would be prohibitive to what I'm trying to accomplish. The API call for specific customers only seems to return the main contact info, so that doesn't work for what I need.

How can I get a list of the people from a specific company?

+1

You should create a macro which returns the information you need, and you can call this macro from API with the company id.

That did the trick. Thanks.

Another approach would be to create a custom column with the neccesary information. Add this custom column to a view and retrieve the view through the browser API.

+1

I just did a quick check in my code and noticed that I could retrieve the persons (schema: #/components/schemas/CustomerPersonDTO) within the call to /customers/{id}

In order to get that information, you need to embed the persons by adding this as a query parameter, so you should call /customers/{id}?embed=persons

Dennis, is there a resource I can reference that outlines the available query parameters per entity type? And possibly a usage overview? 

Thanks!

I use the XTRF API reference. You can navigate to the home-api: https://xtrf.eu/api-doc/#/home-api

If you scroll down to /customers/{customerId} and open that panel, you can see the available query parameters and path parameters.

Oh I see. And in this case `persons` is the only param for this endpoint.