VB.NET UWP/WinRT Dynamics CRM: Get All Information for a Specific Incident

Back to Index

Returns the entire JSON record for a specific incident.

Documentation: https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/incident?view=dynamics-ce-odata-9

CURL Command

curl -X GET https://my-dynamics-domain.api.crm.dynamics.com/api/data/v9.0/incidents \
  -H "Accept: application/json" \
  -H "OData-MaxVersion: 4.0"  \
  -H "OData-Version: 4.0" \
  -d "$expand=customerid_account($select=accountid,name)" \
  -d "$filter=incidentid eq c49e62a8-90df-e311-9565-a45d36fc5fe8" \
  -H "Authorization: Bearer DYNAMICS_CRM_ACCESS_TOKEN"

VB.NET UWP/WinRT Example

Dim rest As New Chilkat.Rest
Dim success As Boolean

'  URL: https://my-dynamics-domain.api.crm.dynamics.com/api/data/v9.0/incidents
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("$expand","customerid_account($select=accountid,name)")
rest.AddQueryParam("$filter","incidentid eq c49e62a8-90df-e311-9565-a45d36fc5fe8")

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/incidents",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 v_resolvebykpiid_value As String = jsonResponse.StringOf("value[i]._resolvebykpiid_value")
    Dim customercontacted As Boolean = jsonResponse.BoolOf("value[i].customercontacted")
    Dim v_accountid_value As String = jsonResponse.StringOf("value[i]._accountid_value")
    Dim prioritycode As Integer = jsonResponse.IntOf("value[i].prioritycode")
    Dim v_msdyn_incidenttype_value As String = jsonResponse.StringOf("value[i]._msdyn_incidenttype_value")
    Dim caseorigincode As Integer = jsonResponse.IntOf("value[i].caseorigincode")
    Dim modifiedon As String = jsonResponse.StringOf("value[i].modifiedon")
    Dim v_parentcaseid_value As String = jsonResponse.StringOf("value[i]._parentcaseid_value")
    Dim v_slainvokedid_value As String = jsonResponse.StringOf("value[i]._slainvokedid_value")
    Dim overriddencreatedon As String = jsonResponse.StringOf("value[i].overriddencreatedon")
    Dim isescalated As Boolean = jsonResponse.BoolOf("value[i].isescalated")
    Dim int_paraturecasenumber As String = jsonResponse.StringOf("value[i].int_paraturecasenumber")
    Dim checkemail As Boolean = jsonResponse.BoolOf("value[i].checkemail")
    Dim followupby As String = jsonResponse.StringOf("value[i].followupby")
    Dim ticketnumber As String = jsonResponse.StringOf("value[i].ticketnumber")
    Dim versionnumber As Integer = jsonResponse.IntOf("value[i].versionnumber")
    Dim v_modifiedby_value As String = jsonResponse.StringOf("value[i]._modifiedby_value")
    Dim billedserviceunits As String = jsonResponse.StringOf("value[i].billedserviceunits")
    Dim decremententitlementterm As Boolean = jsonResponse.BoolOf("value[i].decremententitlementterm")
    Dim onholdtime As String = jsonResponse.StringOf("value[i].onholdtime")
    Dim resolveby As String = jsonResponse.StringOf("value[i].resolveby")
    Dim int_upsellreferral As Boolean = jsonResponse.BoolOf("value[i].int_upsellreferral")
    Dim messagetypecode As String = jsonResponse.StringOf("value[i].messagetypecode")
    Dim emailaddress As String = jsonResponse.StringOf("value[i].emailaddress")
    Dim merged As Boolean = jsonResponse.BoolOf("value[i].merged")
    Dim int_surveryparticipation As String = jsonResponse.StringOf("value[i].int_surveryparticipation")
    Dim contractservicelevelcode As String = jsonResponse.StringOf("value[i].contractservicelevelcode")
    Dim v_createdonbehalfby_value As String = jsonResponse.StringOf("value[i]._createdonbehalfby_value")
    Dim v_contactid_value As String = jsonResponse.StringOf("value[i]._contactid_value")
    Dim v_existingcase_value As String = jsonResponse.StringOf("value[i]._existingcase_value")
    Dim productserialnumber As String = jsonResponse.StringOf("value[i].productserialnumber")
    Dim v_owninguser_value As String = jsonResponse.StringOf("value[i]._owninguser_value")
    Dim int_effortnum As String = jsonResponse.StringOf("value[i].int_effortnum")
    Dim escalatedon As String = jsonResponse.StringOf("value[i].escalatedon")
    Dim v_productid_value As String = jsonResponse.StringOf("value[i]._productid_value")
    Dim followuptaskcreated As Boolean = jsonResponse.BoolOf("value[i].followuptaskcreated")
    Dim v_ownerid_value As String = jsonResponse.StringOf("value[i]._ownerid_value")
    Dim new_actualsatisfaction As String = jsonResponse.StringOf("value[i].new_actualsatisfaction")
    Dim v_socialprofileid_value As String = jsonResponse.StringOf("value[i]._socialprofileid_value")
    Dim v_createdbyexternalparty_value As String = jsonResponse.StringOf("value[i]._createdbyexternalparty_value")
    Dim v_contractid_value As String = jsonResponse.StringOf("value[i]._contractid_value")
    Dim v_modifiedbyexternalparty_value As String = jsonResponse.StringOf("value[i]._modifiedbyexternalparty_value")
    Dim v_masterid_value As String = jsonResponse.StringOf("value[i]._masterid_value")
    Dim timezoneruleversionnumber As Integer = jsonResponse.IntOf("value[i].timezoneruleversionnumber")
    Dim entityimageid As String = jsonResponse.StringOf("value[i].entityimageid")
    Dim v_primarycontactid_value As String = jsonResponse.StringOf("value[i]._primarycontactid_value")
    Dim importsequencenumber As Integer = jsonResponse.IntOf("value[i].importsequencenumber")
    Dim v_owningteam_value As String = jsonResponse.StringOf("value[i]._owningteam_value")
    Dim routecase As Boolean = jsonResponse.BoolOf("value[i].routecase")
    Dim blockedprofile As Boolean = jsonResponse.BoolOf("value[i].blockedprofile")
    Dim statecode As Integer = jsonResponse.IntOf("value[i].statecode")
    Dim int_casecategory As String = jsonResponse.StringOf("value[i].int_casecategory")
    Dim entityimage_timestamp As String = jsonResponse.StringOf("value[i].entityimage_timestamp")
    Dim firstresponseslastatus As Integer = jsonResponse.IntOf("value[i].firstresponseslastatus")
    Dim traversedpath As String = jsonResponse.StringOf("value[i].traversedpath")
    Dim int_actualsatisfaction As String = jsonResponse.StringOf("value[i].int_actualsatisfaction")
    Dim v_int_associatedproduct_value As String = jsonResponse.StringOf("value[i]._int_associatedproduct_value")
    Dim v_customerid_value As String = jsonResponse.StringOf("value[i]._customerid_value")
    Dim entityimage As String = jsonResponse.StringOf("value[i].entityimage")
    Dim v_entitlementid_value As String = jsonResponse.StringOf("value[i]._entitlementid_value")
    Dim activitiescomplete As Boolean = jsonResponse.BoolOf("value[i].activitiescomplete")
    Dim new_upsellreferral As String = jsonResponse.StringOf("value[i].new_upsellreferral")
    Dim statuscode As Integer = jsonResponse.IntOf("value[i].statuscode")
    Dim processid As String = jsonResponse.StringOf("value[i].processid")
    Dim v_contractdetailid_value As String = jsonResponse.StringOf("value[i]._contractdetailid_value")
    Dim int_customereffort As Integer = jsonResponse.IntOf("value[i].int_customereffort")
    Dim responseby As String = jsonResponse.StringOf("value[i].responseby")
    Dim v_transactioncurrencyid_value As String = jsonResponse.StringOf("value[i]._transactioncurrencyid_value")
    Dim sentimentvalue As String = jsonResponse.StringOf("value[i].sentimentvalue")
    Dim v_slaid_value As String = jsonResponse.StringOf("value[i]._slaid_value")
    Dim influencescore As String = jsonResponse.StringOf("value[i].influencescore")
    Dim v_firstresponsebykpiid_value As String = jsonResponse.StringOf("value[i]._firstresponsebykpiid_value")
    Dim utcconversiontimezonecode As String = jsonResponse.StringOf("value[i].utcconversiontimezonecode")
    Dim numberofchildincidents As String = jsonResponse.StringOf("value[i].numberofchildincidents")
    Dim incidentid As String = jsonResponse.StringOf("value[i].incidentid")
    Dim new_casecategory As String = jsonResponse.StringOf("value[i].new_casecategory")
    Dim v_owningbusinessunit_value As String = jsonResponse.StringOf("value[i]._owningbusinessunit_value")
    Dim casetypecode As Integer = jsonResponse.IntOf("value[i].casetypecode")
    Dim resolvebyslastatus As Integer = jsonResponse.IntOf("value[i].resolvebyslastatus")
    Dim createdon As String = jsonResponse.StringOf("value[i].createdon")
    Dim severitycode As Integer = jsonResponse.IntOf("value[i].severitycode")
    Dim exchangerate As String = jsonResponse.StringOf("value[i].exchangerate")
    Dim v_subjectid_value As String = jsonResponse.StringOf("value[i]._subjectid_value")
    Dim servicestage As Integer = jsonResponse.IntOf("value[i].servicestage")
    Dim description As String = jsonResponse.StringOf("value[i].description")
    Dim lastonholdtime As String = jsonResponse.StringOf("value[i].lastonholdtime")
    Dim actualserviceunits As String = jsonResponse.StringOf("value[i].actualserviceunits")
    Dim title As String = jsonResponse.StringOf("value[i].title")
    Dim v_createdby_value As String = jsonResponse.StringOf("value[i]._createdby_value")
    Dim isdecrementing As Boolean = jsonResponse.BoolOf("value[i].isdecrementing")
    Dim v_modifiedonbehalfby_value As String = jsonResponse.StringOf("value[i]._modifiedonbehalfby_value")
    Dim customersatisfactioncode As Integer = jsonResponse.IntOf("value[i].customersatisfactioncode")
    Dim stageid As String = jsonResponse.StringOf("value[i].stageid")
    Dim v_kbarticleid_value As String = jsonResponse.StringOf("value[i]._kbarticleid_value")
    Dim entityimage_url As String = jsonResponse.StringOf("value[i].entityimage_url")
    Dim firstresponsesent As Boolean = jsonResponse.BoolOf("value[i].firstresponsesent")
    Dim incidentstagecode As Integer = jsonResponse.IntOf("value[i].incidentstagecode")
    Dim customerid_accountAccountid As String = jsonResponse.StringOf("value[i].customerid_account.accountid")
    Dim customerid_accountName As String = jsonResponse.StringOf("value[i].customerid_account.name")
    i = i + 1
End While

Sample JSON Response Body

{
  "@odata.context": "https://mydomain.api.crm.dynamics.com/api/data/v9.0/$metadata#incidents(customerid_account(accountid,name))",
  "value": [
    {
      "@odata.etag": "W/\"1161596\"",
      "_resolvebykpiid_value": null,
      "customercontacted": false,
      "_accountid_value": null,
      "prioritycode": 2,
      "_msdyn_incidenttype_value": null,
      "caseorigincode": 2,
      "modifiedon": "2018-03-03T12:34:48Z",
      "_parentcaseid_value": null,
      "_slainvokedid_value": null,
      "overriddencreatedon": "2018-03-03T12:34:48Z",
      "isescalated": false,
      "int_paraturecasenumber": null,
      "checkemail": false,
      "followupby": "2015-06-04T16:15:42Z",
      "ticketnumber": "CAS-01220-S1K8F4",
      "versionnumber": 1161596,
      "_modifiedby_value": "32ff7175-0dbe-4acb-872e-22f86435bf98",
      "billedserviceunits": null,
      "decremententitlementterm": true,
      "onholdtime": null,
      "resolveby": "2015-06-05T16:15:42Z",
      "int_upsellreferral": false,
      "messagetypecode": null,
      "emailaddress": null,
      "merged": false,
      "int_surveryparticipation": null,
      "contractservicelevelcode": null,
      "_createdonbehalfby_value": null,
      "_contactid_value": null,
      "_existingcase_value": null,
      "productserialnumber": null,
      "_owninguser_value": "32ff7175-0dbe-4acb-872e-22f86435bf98",
      "int_effortnum": null,
      "escalatedon": null,
      "_productid_value": "3509d8af-7bc3-e411-80df-fc15b42886e8",
      "followuptaskcreated": false,
      "_ownerid_value": "32ff7175-0dbe-4acb-872e-22f86435bf98",
      "new_actualsatisfaction": null,
      "_socialprofileid_value": null,
      "_createdbyexternalparty_value": null,
      "_contractid_value": null,
      "_modifiedbyexternalparty_value": null,
      "_masterid_value": null,
      "timezoneruleversionnumber": 0,
      "entityimageid": null,
      "_primarycontactid_value": null,
      "importsequencenumber": 124,
      "_owningteam_value": null,
      "routecase": true,
      "blockedprofile": false,
      "statecode": 0,
      "int_casecategory": null,
      "entityimage_timestamp": null,
      "firstresponseslastatus": 1,
      "traversedpath": null,
      "int_actualsatisfaction": null,
      "_int_associatedproduct_value": null,
      "_customerid_value": "b6a19cdd-88df-e311-b8e5-6c3be5a8b200",
      "entityimage": null,
      "_entitlementid_value": null,
      "activitiescomplete": false,
      "new_upsellreferral": null,
      "statuscode": 1,
      "processid": "0ffbcde4-61c1-4355-aa89-aa1d7b2b8792",
      "_contractdetailid_value": null,
      "int_customereffort": 121590000,
      "responseby": null,
      "_transactioncurrencyid_value": null,
      "sentimentvalue": null,
      "_slaid_value": null,
      "influencescore": null,
      "_firstresponsebykpiid_value": null,
      "utcconversiontimezonecode": null,
      "numberofchildincidents": null,
      "incidentid": "c49e62a8-90df-e311-9565-a45d36fc5fe8",
      "new_casecategory": null,
      "_owningbusinessunit_value": "c4106190-c81e-e811-a980-000d3a192e9a",
      "casetypecode": 2,
      "resolvebyslastatus": 1,
      "createdon": "2017-01-20T22:50:47Z",
      "severitycode": 1,
      "exchangerate": null,
      "_subjectid_value": "191de3d1-21d5-e411-80eb-c4346bad3638",
      "servicestage": 0,
      "description": null,
      "lastonholdtime": null,
      "actualserviceunits": null,
      "title": "Faulty product catalog",
      "_createdby_value": "32ff7175-0dbe-4acb-872e-22f86435bf98",
      "isdecrementing": false,
      "_modifiedonbehalfby_value": null,
      "customersatisfactioncode": 3,
      "stageid": "92a6721b-d465-4d36-aef7-e8822d7a5a6a",
      "_kbarticleid_value": null,
      "entityimage_url": null,
      "firstresponsesent": false,
      "incidentstagecode": 1,
      "customerid_account": {
        "accountid": "b6a19cdd-88df-e311-b8e5-6c3be5a8b200",
        "name": "Fourth Coffee"
      }
    }
  ]
}