Gets the accountid by name.
curl -X GET https://my-dynamics-domain.api.crm.dynamics.com/api/data/v9.0/accounts
-H "Accept: application/json" \
-H "OData-MaxVersion: 4.0" \
-H "OData-Version: 4.0" \
-d "$select=accountid" \
-d "$filter=name eq 'Blue Yonder Airlines'" \
-H "Authorization: Bearer DYNAMICS_CRM_ACCESS_TOKEN"
Dim rest As New Chilkat.Rest
Dim success As Boolean
' URL: https://my-dynamics-domain.api.crm.dynamics.com/api/data/v9.0/accounts
Dim bTls As Boolean = True
Dim port As Integer = 443
Dim bAutoReconnect As Boolean = True
success = Await rest.ConnectAsync("my-dynamics-domain.api.crm.dynamics.com",port,bTls,bAutoReconnect)
If (success <> True) Then
Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason)
Debug.WriteLine(rest.LastErrorText)
Exit Sub
End If
rest.AddQueryParam("$select","accountid")
rest.AddQueryParam("$filter","name eq 'Blue Yonder Airlines'")
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")
Dim sbResponseBody As New Chilkat.StringBuilder
success = Await rest.FullRequestNoBodySbAsync("GET","/api/data/v9.0/accounts",sbResponseBody)
If (success <> True) Then
Debug.WriteLine(rest.LastErrorText)
Exit Sub
End If
Dim respStatusCode As Integer = rest.ResponseStatusCode
If (respStatusCode >= 400) Then
Debug.WriteLine("Response Status Code = " & respStatusCode)
Debug.WriteLine("Response Header:")
Debug.WriteLine(rest.ResponseHeader)
Debug.WriteLine("Response Body:")
Debug.WriteLine(sbResponseBody.GetAsString())
Exit Sub
End If
Dim jsonResponse As New Chilkat.JsonObject
jsonResponse.LoadSb(sbResponseBody)
Dim i As Integer
Dim count_i As Integer
Dim odataContext As String = jsonResponse.StringOf("""@odata.context""")
i = 0
count_i = jsonResponse.SizeOfArray("value")
While i < count_i
jsonResponse.I = i
Dim odataEtag As String = jsonResponse.StringOf("value[i].""@odata.etag""")
Dim accountid As String = jsonResponse.StringOf("value[i].accountid")
i = i + 1
End While
{
"@odata.context": "https://mydomain.api.crm.dynamics.com/api/data/v9.0/$metadata#accounts(accountid)",
"value": [
{
"@odata.etag": "W/\"1817216\"",
"accountid": "aca19cdd-88df-e311-b8e5-6c3be5a8b200"
}
]
}