Find a contactid given a fullname.
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=contactid" \
-d "$filter=fullname eq 'Tomasz Bochenek'" \
-H "Authorization: Bearer DYNAMICS_CRM_ACCESS_TOKEN"
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
set rest = Server.CreateObject("Chilkat_9_5_0.Rest")
' URL: https://my-dynamics-domain.api.crm.dynamics.com/api/data/v9.0/contacts
bTls = 1
port = 443
bAutoReconnect = 1
success = rest.Connect("my-dynamics-domain.api.crm.dynamics.com",port,bTls,bAutoReconnect)
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "ConnectFailReason: " & rest.ConnectFailReason) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"
End If
success = rest.AddQueryParam("$select","contactid")
success = rest.AddQueryParam("$filter","fullname eq 'Tomasz Bochenek'")
success = rest.AddHeader("OData-MaxVersion","4.0")
success = rest.AddHeader("Accept","application/json")
success = rest.AddHeader("OData-Version","4.0")
success = rest.AddHeader("Authorization","Bearer DYNAMICS_CRM_ACCESS_TOKEN")
set sbResponseBody = Server.CreateObject("Chilkat_9_5_0.StringBuilder")
success = rest.FullRequestNoBodySb("GET","/api/data/v9.0/contacts",sbResponseBody)
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"
End If
respStatusCode = rest.ResponseStatusCode
If (respStatusCode >= 400) Then
Response.Write "<pre>" & Server.HTMLEncode( "Response Status Code = " & respStatusCode) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "Response Header:") & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( rest.ResponseHeader) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "Response Body:") & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( sbResponseBody.GetAsString()) & "</pre>"
End If
set jsonResponse = Server.CreateObject("Chilkat_9_5_0.JsonObject")
success = jsonResponse.LoadSb(sbResponseBody)
odataContext = jsonResponse.StringOf("""@odata.context""")
i = 0
count_i = jsonResponse.SizeOfArray("value")
Do While i < count_i
jsonResponse.I = i
odataEtag = jsonResponse.StringOf("value[i].""@odata.etag""")
contactid = jsonResponse.StringOf("value[i].contactid")
i = i + 1
Loop
%>
</body>
</html>
{
"@odata.context": "https://mydomain.api.crm.dynamics.com/api/data/v9.0/$metadata#contacts(contactid)",
"value": [
{
"@odata.etag": "W/\"1162210\"",
"contactid": "1fa1e5b9-88df-e311-b8e5-6c3be5a8b200"
}
]
}