and gettting response of all contacts but “tag_ids” key with blank array with no “custom_fields” key for all contact.
In below screenshot example of contact #44 (response)
Check out this code that successfully retrieves contact info with tagId’s and custom fields and see if it helps:
try {
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$content = ‘application/x-www-form-urlencoded’
$access_token = ‘The Access token12345’
$contact_id = 142628
$optional_properties = “custom_fields”
$url = “https://api.infusionsoft.com/crm/rest/v1/contacts/${contact_id}?optional_properties=$optional_properties”
$headers = @{}
$headers.Add(“Authorization”, “Bearer $access_token”)
$headers.Add(“Accept”, “application/json, /”)
$get_cont_response = Invoke-RestMethod -URI $url -Method Get -Headers $headers -ContentType $content
} catch {
# On error list StatusCode and Error description
Write-Host “StatusCode:” $.Exception.Response.StatusCode.value__
Write-Host “StatusDescription:” $.Exception.Response.StatusDescription
}
# List structure received
$get_cont_response
email_addresses : {@{email=obie1@xandu.me; field=EMAIL1}}
email_opted_in : True
addresses : {}
last_updated : 1944-06-06T01:52:04.000+0000
tag_ids : {352, 846, 910, 970...}
owner_id :
date_created : 2017-05-29T15:00:26.000+0000
middle_name :
given_name : Obie1
email_status : SingleOptIn
phone_numbers : {}
company :
id : 142628
family_name : Tesla
custom_fields : {@{id=512; content=}, @{id=256; content=}, @{id=514; content=}, @{id=2; content=}...}
# list TagId's
$get_cont_response.tag_ids
352
846
910
970
1002
# List custom fields that are not blank
$get_cont_response.custom_fields | where {$_.content -gt ' '} | sort id
id content
-- -------
6 School of Hard Knocks
8 Jones County
60 TestAccountPID
272 Testing this page.....
461 n/a
488 2018-04-02
528 Day of Fun
530 IXA is
We don’t return Custom Fields and Tags on REST List responses for database performance reasons; you can see them on individual GET /contacts/{id} entries by specifying “&optional_properties=custom_fields” on the call.