Tcl 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"

Tcl Example


load ./chilkat.dll

set rest [new_CkRest]

#  URL: https://my-dynamics-domain.api.crm.dynamics.com/api/data/v9.0/incidents
set bTls 1
set port 443
set bAutoReconnect 1
set success [CkRest_Connect $rest "my-dynamics-domain.api.crm.dynamics.com" $port $bTls $bAutoReconnect]
if {[expr $success != 1]} then {
    puts "ConnectFailReason: [CkRest_ConnectFailReason $rest]"
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    exit
}

CkRest_AddQueryParam $rest "$expand" "customerid_account($select=accountid,name)"
CkRest_AddQueryParam $rest "$filter" "incidentid eq c49e62a8-90df-e311-9565-a45d36fc5fe8"

CkRest_AddHeader $rest "OData-MaxVersion" "4.0"
CkRest_AddHeader $rest "Accept" "application/json"
CkRest_AddHeader $rest "OData-Version" "4.0"
CkRest_AddHeader $rest "Authorization" "Bearer DYNAMICS_CRM_ACCESS_TOKEN"

set sbResponseBody [new_CkStringBuilder]

set success [CkRest_FullRequestNoBodySb $rest "GET" "/api/data/v9.0/incidents" $sbResponseBody]
if {[expr $success != 1]} then {
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    delete_CkStringBuilder $sbResponseBody
    exit
}

set respStatusCode [CkRest_ResponseStatusCode $rest]
if {[expr $respStatusCode >= 400]} then {
    puts "Response Status Code = $respStatusCode"
    puts "Response Header:"
    puts [CkRest_responseHeader $rest]
    puts "Response Body:"
    puts [CkStringBuilder_getAsString $sbResponseBody]
    delete_CkRest $rest
    delete_CkStringBuilder $sbResponseBody
    exit
}

set jsonResponse [new_CkJsonObject]

CkJsonObject_LoadSb $jsonResponse $sbResponseBody

set odataContext [CkJsonObject_stringOf $jsonResponse "\"@odata.context\""]
set i 0
set count_i [CkJsonObject_SizeOfArray $jsonResponse "value"]
while {[expr $i < $count_i]} {
    CkJsonObject_put_I $jsonResponse $i
    set odataEtag [CkJsonObject_stringOf $jsonResponse "value[i].\"@odata.etag\""]
    set v_resolvebykpiid_value [CkJsonObject_stringOf $jsonResponse "value[i]._resolvebykpiid_value"]
    set customercontacted [CkJsonObject_BoolOf $jsonResponse "value[i].customercontacted"]
    set v_accountid_value [CkJsonObject_stringOf $jsonResponse "value[i]._accountid_value"]
    set prioritycode [CkJsonObject_IntOf $jsonResponse "value[i].prioritycode"]
    set v_msdyn_incidenttype_value [CkJsonObject_stringOf $jsonResponse "value[i]._msdyn_incidenttype_value"]
    set caseorigincode [CkJsonObject_IntOf $jsonResponse "value[i].caseorigincode"]
    set modifiedon [CkJsonObject_stringOf $jsonResponse "value[i].modifiedon"]
    set v_parentcaseid_value [CkJsonObject_stringOf $jsonResponse "value[i]._parentcaseid_value"]
    set v_slainvokedid_value [CkJsonObject_stringOf $jsonResponse "value[i]._slainvokedid_value"]
    set overriddencreatedon [CkJsonObject_stringOf $jsonResponse "value[i].overriddencreatedon"]
    set isescalated [CkJsonObject_BoolOf $jsonResponse "value[i].isescalated"]
    set int_paraturecasenumber [CkJsonObject_stringOf $jsonResponse "value[i].int_paraturecasenumber"]
    set checkemail [CkJsonObject_BoolOf $jsonResponse "value[i].checkemail"]
    set followupby [CkJsonObject_stringOf $jsonResponse "value[i].followupby"]
    set ticketnumber [CkJsonObject_stringOf $jsonResponse "value[i].ticketnumber"]
    set versionnumber [CkJsonObject_IntOf $jsonResponse "value[i].versionnumber"]
    set v_modifiedby_value [CkJsonObject_stringOf $jsonResponse "value[i]._modifiedby_value"]
    set billedserviceunits [CkJsonObject_stringOf $jsonResponse "value[i].billedserviceunits"]
    set decremententitlementterm [CkJsonObject_BoolOf $jsonResponse "value[i].decremententitlementterm"]
    set onholdtime [CkJsonObject_stringOf $jsonResponse "value[i].onholdtime"]
    set resolveby [CkJsonObject_stringOf $jsonResponse "value[i].resolveby"]
    set int_upsellreferral [CkJsonObject_BoolOf $jsonResponse "value[i].int_upsellreferral"]
    set messagetypecode [CkJsonObject_stringOf $jsonResponse "value[i].messagetypecode"]
    set emailaddress [CkJsonObject_stringOf $jsonResponse "value[i].emailaddress"]
    set merged [CkJsonObject_BoolOf $jsonResponse "value[i].merged"]
    set int_surveryparticipation [CkJsonObject_stringOf $jsonResponse "value[i].int_surveryparticipation"]
    set contractservicelevelcode [CkJsonObject_stringOf $jsonResponse "value[i].contractservicelevelcode"]
    set v_createdonbehalfby_value [CkJsonObject_stringOf $jsonResponse "value[i]._createdonbehalfby_value"]
    set v_contactid_value [CkJsonObject_stringOf $jsonResponse "value[i]._contactid_value"]
    set v_existingcase_value [CkJsonObject_stringOf $jsonResponse "value[i]._existingcase_value"]
    set productserialnumber [CkJsonObject_stringOf $jsonResponse "value[i].productserialnumber"]
    set v_owninguser_value [CkJsonObject_stringOf $jsonResponse "value[i]._owninguser_value"]
    set int_effortnum [CkJsonObject_stringOf $jsonResponse "value[i].int_effortnum"]
    set escalatedon [CkJsonObject_stringOf $jsonResponse "value[i].escalatedon"]
    set v_productid_value [CkJsonObject_stringOf $jsonResponse "value[i]._productid_value"]
    set followuptaskcreated [CkJsonObject_BoolOf $jsonResponse "value[i].followuptaskcreated"]
    set v_ownerid_value [CkJsonObject_stringOf $jsonResponse "value[i]._ownerid_value"]
    set new_actualsatisfaction [CkJsonObject_stringOf $jsonResponse "value[i].new_actualsatisfaction"]
    set v_socialprofileid_value [CkJsonObject_stringOf $jsonResponse "value[i]._socialprofileid_value"]
    set v_createdbyexternalparty_value [CkJsonObject_stringOf $jsonResponse "value[i]._createdbyexternalparty_value"]
    set v_contractid_value [CkJsonObject_stringOf $jsonResponse "value[i]._contractid_value"]
    set v_modifiedbyexternalparty_value [CkJsonObject_stringOf $jsonResponse "value[i]._modifiedbyexternalparty_value"]
    set v_masterid_value [CkJsonObject_stringOf $jsonResponse "value[i]._masterid_value"]
    set timezoneruleversionnumber [CkJsonObject_IntOf $jsonResponse "value[i].timezoneruleversionnumber"]
    set entityimageid [CkJsonObject_stringOf $jsonResponse "value[i].entityimageid"]
    set v_primarycontactid_value [CkJsonObject_stringOf $jsonResponse "value[i]._primarycontactid_value"]
    set importsequencenumber [CkJsonObject_IntOf $jsonResponse "value[i].importsequencenumber"]
    set v_owningteam_value [CkJsonObject_stringOf $jsonResponse "value[i]._owningteam_value"]
    set routecase [CkJsonObject_BoolOf $jsonResponse "value[i].routecase"]
    set blockedprofile [CkJsonObject_BoolOf $jsonResponse "value[i].blockedprofile"]
    set statecode [CkJsonObject_IntOf $jsonResponse "value[i].statecode"]
    set int_casecategory [CkJsonObject_stringOf $jsonResponse "value[i].int_casecategory"]
    set entityimage_timestamp [CkJsonObject_stringOf $jsonResponse "value[i].entityimage_timestamp"]
    set firstresponseslastatus [CkJsonObject_IntOf $jsonResponse "value[i].firstresponseslastatus"]
    set traversedpath [CkJsonObject_stringOf $jsonResponse "value[i].traversedpath"]
    set int_actualsatisfaction [CkJsonObject_stringOf $jsonResponse "value[i].int_actualsatisfaction"]
    set v_int_associatedproduct_value [CkJsonObject_stringOf $jsonResponse "value[i]._int_associatedproduct_value"]
    set v_customerid_value [CkJsonObject_stringOf $jsonResponse "value[i]._customerid_value"]
    set entityimage [CkJsonObject_stringOf $jsonResponse "value[i].entityimage"]
    set v_entitlementid_value [CkJsonObject_stringOf $jsonResponse "value[i]._entitlementid_value"]
    set activitiescomplete [CkJsonObject_BoolOf $jsonResponse "value[i].activitiescomplete"]
    set new_upsellreferral [CkJsonObject_stringOf $jsonResponse "value[i].new_upsellreferral"]
    set statuscode [CkJsonObject_IntOf $jsonResponse "value[i].statuscode"]
    set processid [CkJsonObject_stringOf $jsonResponse "value[i].processid"]
    set v_contractdetailid_value [CkJsonObject_stringOf $jsonResponse "value[i]._contractdetailid_value"]
    set int_customereffort [CkJsonObject_IntOf $jsonResponse "value[i].int_customereffort"]
    set responseby [CkJsonObject_stringOf $jsonResponse "value[i].responseby"]
    set v_transactioncurrencyid_value [CkJsonObject_stringOf $jsonResponse "value[i]._transactioncurrencyid_value"]
    set sentimentvalue [CkJsonObject_stringOf $jsonResponse "value[i].sentimentvalue"]
    set v_slaid_value [CkJsonObject_stringOf $jsonResponse "value[i]._slaid_value"]
    set influencescore [CkJsonObject_stringOf $jsonResponse "value[i].influencescore"]
    set v_firstresponsebykpiid_value [CkJsonObject_stringOf $jsonResponse "value[i]._firstresponsebykpiid_value"]
    set utcconversiontimezonecode [CkJsonObject_stringOf $jsonResponse "value[i].utcconversiontimezonecode"]
    set numberofchildincidents [CkJsonObject_stringOf $jsonResponse "value[i].numberofchildincidents"]
    set incidentid [CkJsonObject_stringOf $jsonResponse "value[i].incidentid"]
    set new_casecategory [CkJsonObject_stringOf $jsonResponse "value[i].new_casecategory"]
    set v_owningbusinessunit_value [CkJsonObject_stringOf $jsonResponse "value[i]._owningbusinessunit_value"]
    set casetypecode [CkJsonObject_IntOf $jsonResponse "value[i].casetypecode"]
    set resolvebyslastatus [CkJsonObject_IntOf $jsonResponse "value[i].resolvebyslastatus"]
    set createdon [CkJsonObject_stringOf $jsonResponse "value[i].createdon"]
    set severitycode [CkJsonObject_IntOf $jsonResponse "value[i].severitycode"]
    set exchangerate [CkJsonObject_stringOf $jsonResponse "value[i].exchangerate"]
    set v_subjectid_value [CkJsonObject_stringOf $jsonResponse "value[i]._subjectid_value"]
    set servicestage [CkJsonObject_IntOf $jsonResponse "value[i].servicestage"]
    set description [CkJsonObject_stringOf $jsonResponse "value[i].description"]
    set lastonholdtime [CkJsonObject_stringOf $jsonResponse "value[i].lastonholdtime"]
    set actualserviceunits [CkJsonObject_stringOf $jsonResponse "value[i].actualserviceunits"]
    set title [CkJsonObject_stringOf $jsonResponse "value[i].title"]
    set v_createdby_value [CkJsonObject_stringOf $jsonResponse "value[i]._createdby_value"]
    set isdecrementing [CkJsonObject_BoolOf $jsonResponse "value[i].isdecrementing"]
    set v_modifiedonbehalfby_value [CkJsonObject_stringOf $jsonResponse "value[i]._modifiedonbehalfby_value"]
    set customersatisfactioncode [CkJsonObject_IntOf $jsonResponse "value[i].customersatisfactioncode"]
    set stageid [CkJsonObject_stringOf $jsonResponse "value[i].stageid"]
    set v_kbarticleid_value [CkJsonObject_stringOf $jsonResponse "value[i]._kbarticleid_value"]
    set entityimage_url [CkJsonObject_stringOf $jsonResponse "value[i].entityimage_url"]
    set firstresponsesent [CkJsonObject_BoolOf $jsonResponse "value[i].firstresponsesent"]
    set incidentstagecode [CkJsonObject_IntOf $jsonResponse "value[i].incidentstagecode"]
    set customerid_accountAccountid [CkJsonObject_stringOf $jsonResponse "value[i].customerid_account.accountid"]
    set customerid_accountName [CkJsonObject_stringOf $jsonResponse "value[i].customerid_account.name"]
    set i [expr $i + 1]
}

delete_CkRest $rest
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $jsonResponse

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"
      }
    }
  ]
}