How to use $select API?
The documentation for the
contacts endpoint says "$select - Controls which fields are returned in the Contacts API call."
Dmitry Smirnov provided some examples in the post below.
His example was:
$select='First name','Last name',Phone
I'm not seeing a difference in the API response with or without the select, and I'd love to use it to reduce the amount of data being returned.
Below is a cURL example:
curl -X GET \
'https://api.wildapricot.org/v2/Accounts/$MY_ACCOUNT_ID/Contacts?$async=false&$select=%27First Name%27,%27Last Name%27,%27Email%27' \
-H 'Accept: /' \
-H 'Authorization: Bearer $MY_TOKEN' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Host: api.wildapricot.org' \
-H 'accept-encoding: gzip, deflate'
I've also tried $select='FirstName','LastName','Email' to remove spaces and match the casing of the keys returned in the JSON.
Tim Daniel commented
Thanks for providing some insight to this Dmitry! I captured the URL from my latest of many unsuccessful attempts to get this to work. I hate to ask this, but I have really exhausted all the possibilities I can think of with different variations of the URL. I have checked the field names several times. Can you please tell me where the error is:
I also did this:
In both cases, the API returned the entire list of contact fields.
I also tried different versions of the API, 2.1 vs 2.2 etc.
I'm pretty much at a loss. I have code that can produce just about any variation of the call, but I can't seem to get any variation to work.
Thank in advance for any help.
In general you request looks right. The thing I would check is field names in your account. Use this endpoint to get full list of all contact fields. You need to pass 'FieldName' as a select parameter. https://app.swaggerhub.com/apis-docs/WildApricot/wild-apricot_public_api/2.1.0#/Contacts.CustomFields/GetContactFieldDefinitions
Another possible thing is a misuse of ’ instead '. They look similar for human, but API works with ' only. MacOS likes to replace ' with ’.
This API call I just checked and it works as expected