Returns the full name, email address, and phone number for each of an account's contacts. This example gets the contacts for the Coho Winery account (accountid = b0a19cdd-88df-e311-b8e5-6c3be5a8b200).
curl -X GET https://my-dynamics-domain.api.crm.dynamics.com/api/data/v9.0/contacts \
-H "Accept: application/json" \
-H "OData-MaxVersion: 4.0" \
-H "OData-Version: 4.0" \
-d "$select=fullname,emailaddress1,telephone1" \
-d "$filter=_parentcustomerid_value eq b0a19cdd-88df-e311-b8e5-6c3be5a8b200" \
-H "Authorization: Bearer DYNAMICS_CRM_ACCESS_TOKEN"
import sys
import chilkat
rest = chilkat.CkRest()
# URL: https://my-dynamics-domain.api.crm.dynamics.com/api/data/v9.0/contacts
bTls = True
port = 443
bAutoReconnect = True
success = rest.Connect("my-dynamics-domain.api.crm.dynamics.com",port,bTls,bAutoReconnect)
if (success != True):
print("ConnectFailReason: " + str(rest.get_ConnectFailReason()))
print(rest.lastErrorText())
sys.exit()
rest.AddQueryParam("$select","fullname,emailaddress1,telephone1")
rest.AddQueryParam("$filter","_parentcustomerid_value eq b0a19cdd-88df-e311-b8e5-6c3be5a8b200")
rest.AddHeader("OData-MaxVersion","4.0")
rest.AddHeader("Accept","application/json")
rest.AddHeader("OData-Version","4.0")
rest.AddHeader("Authorization","Bearer DYNAMICS_CRM_ACCESS_TOKEN")
sbResponseBody = chilkat.CkStringBuilder()
success = rest.FullRequestNoBodySb("GET","/api/data/v9.0/contacts",sbResponseBody)
if (success != True):
print(rest.lastErrorText())
sys.exit()
respStatusCode = rest.get_ResponseStatusCode()
if (respStatusCode >= 400):
print("Response Status Code = " + str(respStatusCode))
print("Response Header:")
print(rest.responseHeader())
print("Response Body:")
print(sbResponseBody.getAsString())
sys.exit()
jsonResponse = chilkat.CkJsonObject()
jsonResponse.LoadSb(sbResponseBody)
odataContext = jsonResponse.stringOf("\"@odata.context\"")
i = 0
count_i = jsonResponse.SizeOfArray("value")
while i < count_i :
jsonResponse.put_I(i)
odataEtag = jsonResponse.stringOf("value[i].\"@odata.etag\"")
fullname = jsonResponse.stringOf("value[i].fullname")
emailaddress1 = jsonResponse.stringOf("value[i].emailaddress1")
telephone1 = jsonResponse.stringOf("value[i].telephone1")
contactid = jsonResponse.stringOf("value[i].contactid")
i = i + 1
{
"@odata.context": "https://mydomain.api.crm.dynamics.com/api/data/v9.0/$metadata#contacts(fullname,emailaddress1,telephone1)",
"value": [
{
"@odata.etag": "W/\"1162014\"",
"fullname": "Cat Francis",
"emailaddress1": "Cat@cohowinery.com",
"telephone1": "123-879-9879",
"contactid": "51a0e5b9-88df-e311-b8e5-6c3be5a8b200"
},
{
"@odata.etag": "W/\"1162210\"",
"fullname": "Tomasz Bochenek",
"emailaddress1": "tom@cohowinery.com",
"telephone1": "456-698-4581",
"contactid": "1fa1e5b9-88df-e311-b8e5-6c3be5a8b200"
},
{
"@odata.etag": "W/\"1162593\"",
"fullname": "Kari Furse",
"emailaddress1": "kari@cohowinery.com",
"telephone1": "178-854-4576",
"contactid": "9ba2e5b9-88df-e311-b8e5-6c3be5a8b200"
},
{
"@odata.etag": "W/\"1162714\"",
"fullname": "Wilson Pais",
"emailaddress1": "wilson@cohowinery.com",
"telephone1": "456-698-4582",
"contactid": "6fa5e5b9-88df-e311-b8e5-6c3be5a8b200"
}
]
}