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

DataFlex Example

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoRest
    Boolean iSuccess
    Boolean iBTls
    Integer iPort
    Boolean iBAutoReconnect
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Integer iRespStatusCode
    Handle hoJsonResponse
    Integer i
    Integer iCount_i
    String sOdataContext
    String sOdataEtag
    String sV_resolvebykpiid_value
    Boolean iCustomercontacted
    String sV_accountid_value
    Integer iPrioritycode
    String sV_msdyn_incidenttype_value
    Integer iCaseorigincode
    String sModifiedon
    String sV_parentcaseid_value
    String sV_slainvokedid_value
    String sOverriddencreatedon
    Boolean iIsescalated
    String sInt_paraturecasenumber
    Boolean iCheckemail
    String sFollowupby
    String sTicketnumber
    Integer iVersionnumber
    String sV_modifiedby_value
    String sBilledserviceunits
    Boolean iDecremententitlementterm
    String sOnholdtime
    String sResolveby
    Boolean iInt_upsellreferral
    String sMessagetypecode
    String sEmailaddress
    Boolean iMerged
    String sInt_surveryparticipation
    String sContractservicelevelcode
    String sV_createdonbehalfby_value
    String sV_contactid_value
    String sV_existingcase_value
    String sProductserialnumber
    String sV_owninguser_value
    String sInt_effortnum
    String sEscalatedon
    String sV_productid_value
    Boolean iFollowuptaskcreated
    String sV_ownerid_value
    String sNew_actualsatisfaction
    String sV_socialprofileid_value
    String sV_createdbyexternalparty_value
    String sV_contractid_value
    String sV_modifiedbyexternalparty_value
    String sV_masterid_value
    Integer iTimezoneruleversionnumber
    String sEntityimageid
    String sV_primarycontactid_value
    Integer iImportsequencenumber
    String sV_owningteam_value
    Boolean iRoutecase
    Boolean iBlockedprofile
    Integer iStatecode
    String sInt_casecategory
    String sEntityimage_timestamp
    Integer iFirstresponseslastatus
    String sTraversedpath
    String sInt_actualsatisfaction
    String sV_int_associatedproduct_value
    String sV_customerid_value
    String sEntityimage
    String sV_entitlementid_value
    Boolean iActivitiescomplete
    String sNew_upsellreferral
    Integer iStatuscode
    String sProcessid
    String sV_contractdetailid_value
    Integer iInt_customereffort
    String sResponseby
    String sV_transactioncurrencyid_value
    String sSentimentvalue
    String sV_slaid_value
    String sInfluencescore
    String sV_firstresponsebykpiid_value
    String sUtcconversiontimezonecode
    String sNumberofchildincidents
    String sIncidentid
    String sNew_casecategory
    String sV_owningbusinessunit_value
    Integer iCasetypecode
    Integer iResolvebyslastatus
    String sCreatedon
    Integer iSeveritycode
    String sExchangerate
    String sV_subjectid_value
    Integer iServicestage
    String sDescription
    String sLastonholdtime
    String sActualserviceunits
    String sTitle
    String sV_createdby_value
    Boolean iIsdecrementing
    String sV_modifiedonbehalfby_value
    Integer iCustomersatisfactioncode
    String sStageid
    String sV_kbarticleid_value
    String sEntityimage_url
    Boolean iFirstresponsesent
    Integer iIncidentstagecode
    String sCustomerid_accountAccountid
    String sCustomerid_accountName
    String sTemp1
    Integer iTemp1

    Get Create (RefClass(cComChilkatRest)) To hoRest
    If (Not(IsComObjectCreated(hoRest))) Begin
        Send CreateComObject of hoRest
    End

    //  URL: https://my-dynamics-domain.api.crm.dynamics.com/api/data/v9.0/incidents
    Move True To iBTls
    Move 443 To iPort
    Move True To iBAutoReconnect
    Get ComConnect Of hoRest "my-dynamics-domain.api.crm.dynamics.com" iPort iBTls iBAutoReconnect To iSuccess
    If (iSuccess <> True) Begin
        Get ComConnectFailReason Of hoRest To iTemp1
        Showln "ConnectFailReason: " iTemp1
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComAddQueryParam Of hoRest "$expand" "customerid_account($select=accountid,name)" To iSuccess
    Get ComAddQueryParam Of hoRest "$filter" "incidentid eq c49e62a8-90df-e311-9565-a45d36fc5fe8" To iSuccess

    Get ComAddHeader Of hoRest "OData-MaxVersion" "4.0" To iSuccess
    Get ComAddHeader Of hoRest "Accept" "application/json" To iSuccess
    Get ComAddHeader Of hoRest "OData-Version" "4.0" To iSuccess
    Get ComAddHeader Of hoRest "Authorization" "Bearer DYNAMICS_CRM_ACCESS_TOKEN" To iSuccess

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComFullRequestNoBodySb Of hoRest "GET" "/api/data/v9.0/incidents" vSbResponseBody To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComResponseStatusCode Of hoRest To iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Status Code = " iRespStatusCode
        Showln "Response Header:"
        Get ComResponseHeader Of hoRest To sTemp1
        Showln sTemp1
        Showln "Response Body:"
        Get ComGetAsString Of hoSbResponseBody To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJsonResponse
    If (Not(IsComObjectCreated(hoJsonResponse))) Begin
        Send CreateComObject of hoJsonResponse
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJsonResponse vSbResponseBody To iSuccess

    Get ComStringOf Of hoJsonResponse '"@odata.context"' To sOdataContext
    Move 0 To i
    Get ComSizeOfArray Of hoJsonResponse "value" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJsonResponse To i
        Get ComStringOf Of hoJsonResponse 'value[i]."@odata.etag"' To sOdataEtag
        Get ComStringOf Of hoJsonResponse "value[i]._resolvebykpiid_value" To sV_resolvebykpiid_value
        Get ComBoolOf Of hoJsonResponse "value[i].customercontacted" To iCustomercontacted
        Get ComStringOf Of hoJsonResponse "value[i]._accountid_value" To sV_accountid_value
        Get ComIntOf Of hoJsonResponse "value[i].prioritycode" To iPrioritycode
        Get ComStringOf Of hoJsonResponse "value[i]._msdyn_incidenttype_value" To sV_msdyn_incidenttype_value
        Get ComIntOf Of hoJsonResponse "value[i].caseorigincode" To iCaseorigincode
        Get ComStringOf Of hoJsonResponse "value[i].modifiedon" To sModifiedon
        Get ComStringOf Of hoJsonResponse "value[i]._parentcaseid_value" To sV_parentcaseid_value
        Get ComStringOf Of hoJsonResponse "value[i]._slainvokedid_value" To sV_slainvokedid_value
        Get ComStringOf Of hoJsonResponse "value[i].overriddencreatedon" To sOverriddencreatedon
        Get ComBoolOf Of hoJsonResponse "value[i].isescalated" To iIsescalated
        Get ComStringOf Of hoJsonResponse "value[i].int_paraturecasenumber" To sInt_paraturecasenumber
        Get ComBoolOf Of hoJsonResponse "value[i].checkemail" To iCheckemail
        Get ComStringOf Of hoJsonResponse "value[i].followupby" To sFollowupby
        Get ComStringOf Of hoJsonResponse "value[i].ticketnumber" To sTicketnumber
        Get ComIntOf Of hoJsonResponse "value[i].versionnumber" To iVersionnumber
        Get ComStringOf Of hoJsonResponse "value[i]._modifiedby_value" To sV_modifiedby_value
        Get ComStringOf Of hoJsonResponse "value[i].billedserviceunits" To sBilledserviceunits
        Get ComBoolOf Of hoJsonResponse "value[i].decremententitlementterm" To iDecremententitlementterm
        Get ComStringOf Of hoJsonResponse "value[i].onholdtime" To sOnholdtime
        Get ComStringOf Of hoJsonResponse "value[i].resolveby" To sResolveby
        Get ComBoolOf Of hoJsonResponse "value[i].int_upsellreferral" To iInt_upsellreferral
        Get ComStringOf Of hoJsonResponse "value[i].messagetypecode" To sMessagetypecode
        Get ComStringOf Of hoJsonResponse "value[i].emailaddress" To sEmailaddress
        Get ComBoolOf Of hoJsonResponse "value[i].merged" To iMerged
        Get ComStringOf Of hoJsonResponse "value[i].int_surveryparticipation" To sInt_surveryparticipation
        Get ComStringOf Of hoJsonResponse "value[i].contractservicelevelcode" To sContractservicelevelcode
        Get ComStringOf Of hoJsonResponse "value[i]._createdonbehalfby_value" To sV_createdonbehalfby_value
        Get ComStringOf Of hoJsonResponse "value[i]._contactid_value" To sV_contactid_value
        Get ComStringOf Of hoJsonResponse "value[i]._existingcase_value" To sV_existingcase_value
        Get ComStringOf Of hoJsonResponse "value[i].productserialnumber" To sProductserialnumber
        Get ComStringOf Of hoJsonResponse "value[i]._owninguser_value" To sV_owninguser_value
        Get ComStringOf Of hoJsonResponse "value[i].int_effortnum" To sInt_effortnum
        Get ComStringOf Of hoJsonResponse "value[i].escalatedon" To sEscalatedon
        Get ComStringOf Of hoJsonResponse "value[i]._productid_value" To sV_productid_value
        Get ComBoolOf Of hoJsonResponse "value[i].followuptaskcreated" To iFollowuptaskcreated
        Get ComStringOf Of hoJsonResponse "value[i]._ownerid_value" To sV_ownerid_value
        Get ComStringOf Of hoJsonResponse "value[i].new_actualsatisfaction" To sNew_actualsatisfaction
        Get ComStringOf Of hoJsonResponse "value[i]._socialprofileid_value" To sV_socialprofileid_value
        Get ComStringOf Of hoJsonResponse "value[i]._createdbyexternalparty_value" To sV_createdbyexternalparty_value
        Get ComStringOf Of hoJsonResponse "value[i]._contractid_value" To sV_contractid_value
        Get ComStringOf Of hoJsonResponse "value[i]._modifiedbyexternalparty_value" To sV_modifiedbyexternalparty_value
        Get ComStringOf Of hoJsonResponse "value[i]._masterid_value" To sV_masterid_value
        Get ComIntOf Of hoJsonResponse "value[i].timezoneruleversionnumber" To iTimezoneruleversionnumber
        Get ComStringOf Of hoJsonResponse "value[i].entityimageid" To sEntityimageid
        Get ComStringOf Of hoJsonResponse "value[i]._primarycontactid_value" To sV_primarycontactid_value
        Get ComIntOf Of hoJsonResponse "value[i].importsequencenumber" To iImportsequencenumber
        Get ComStringOf Of hoJsonResponse "value[i]._owningteam_value" To sV_owningteam_value
        Get ComBoolOf Of hoJsonResponse "value[i].routecase" To iRoutecase
        Get ComBoolOf Of hoJsonResponse "value[i].blockedprofile" To iBlockedprofile
        Get ComIntOf Of hoJsonResponse "value[i].statecode" To iStatecode
        Get ComStringOf Of hoJsonResponse "value[i].int_casecategory" To sInt_casecategory
        Get ComStringOf Of hoJsonResponse "value[i].entityimage_timestamp" To sEntityimage_timestamp
        Get ComIntOf Of hoJsonResponse "value[i].firstresponseslastatus" To iFirstresponseslastatus
        Get ComStringOf Of hoJsonResponse "value[i].traversedpath" To sTraversedpath
        Get ComStringOf Of hoJsonResponse "value[i].int_actualsatisfaction" To sInt_actualsatisfaction
        Get ComStringOf Of hoJsonResponse "value[i]._int_associatedproduct_value" To sV_int_associatedproduct_value
        Get ComStringOf Of hoJsonResponse "value[i]._customerid_value" To sV_customerid_value
        Get ComStringOf Of hoJsonResponse "value[i].entityimage" To sEntityimage
        Get ComStringOf Of hoJsonResponse "value[i]._entitlementid_value" To sV_entitlementid_value
        Get ComBoolOf Of hoJsonResponse "value[i].activitiescomplete" To iActivitiescomplete
        Get ComStringOf Of hoJsonResponse "value[i].new_upsellreferral" To sNew_upsellreferral
        Get ComIntOf Of hoJsonResponse "value[i].statuscode" To iStatuscode
        Get ComStringOf Of hoJsonResponse "value[i].processid" To sProcessid
        Get ComStringOf Of hoJsonResponse "value[i]._contractdetailid_value" To sV_contractdetailid_value
        Get ComIntOf Of hoJsonResponse "value[i].int_customereffort" To iInt_customereffort
        Get ComStringOf Of hoJsonResponse "value[i].responseby" To sResponseby
        Get ComStringOf Of hoJsonResponse "value[i]._transactioncurrencyid_value" To sV_transactioncurrencyid_value
        Get ComStringOf Of hoJsonResponse "value[i].sentimentvalue" To sSentimentvalue
        Get ComStringOf Of hoJsonResponse "value[i]._slaid_value" To sV_slaid_value
        Get ComStringOf Of hoJsonResponse "value[i].influencescore" To sInfluencescore
        Get ComStringOf Of hoJsonResponse "value[i]._firstresponsebykpiid_value" To sV_firstresponsebykpiid_value
        Get ComStringOf Of hoJsonResponse "value[i].utcconversiontimezonecode" To sUtcconversiontimezonecode
        Get ComStringOf Of hoJsonResponse "value[i].numberofchildincidents" To sNumberofchildincidents
        Get ComStringOf Of hoJsonResponse "value[i].incidentid" To sIncidentid
        Get ComStringOf Of hoJsonResponse "value[i].new_casecategory" To sNew_casecategory
        Get ComStringOf Of hoJsonResponse "value[i]._owningbusinessunit_value" To sV_owningbusinessunit_value
        Get ComIntOf Of hoJsonResponse "value[i].casetypecode" To iCasetypecode
        Get ComIntOf Of hoJsonResponse "value[i].resolvebyslastatus" To iResolvebyslastatus
        Get ComStringOf Of hoJsonResponse "value[i].createdon" To sCreatedon
        Get ComIntOf Of hoJsonResponse "value[i].severitycode" To iSeveritycode
        Get ComStringOf Of hoJsonResponse "value[i].exchangerate" To sExchangerate
        Get ComStringOf Of hoJsonResponse "value[i]._subjectid_value" To sV_subjectid_value
        Get ComIntOf Of hoJsonResponse "value[i].servicestage" To iServicestage
        Get ComStringOf Of hoJsonResponse "value[i].description" To sDescription
        Get ComStringOf Of hoJsonResponse "value[i].lastonholdtime" To sLastonholdtime
        Get ComStringOf Of hoJsonResponse "value[i].actualserviceunits" To sActualserviceunits
        Get ComStringOf Of hoJsonResponse "value[i].title" To sTitle
        Get ComStringOf Of hoJsonResponse "value[i]._createdby_value" To sV_createdby_value
        Get ComBoolOf Of hoJsonResponse "value[i].isdecrementing" To iIsdecrementing
        Get ComStringOf Of hoJsonResponse "value[i]._modifiedonbehalfby_value" To sV_modifiedonbehalfby_value
        Get ComIntOf Of hoJsonResponse "value[i].customersatisfactioncode" To iCustomersatisfactioncode
        Get ComStringOf Of hoJsonResponse "value[i].stageid" To sStageid
        Get ComStringOf Of hoJsonResponse "value[i]._kbarticleid_value" To sV_kbarticleid_value
        Get ComStringOf Of hoJsonResponse "value[i].entityimage_url" To sEntityimage_url
        Get ComBoolOf Of hoJsonResponse "value[i].firstresponsesent" To iFirstresponsesent
        Get ComIntOf Of hoJsonResponse "value[i].incidentstagecode" To iIncidentstagecode
        Get ComStringOf Of hoJsonResponse "value[i].customerid_account.accountid" To sCustomerid_accountAccountid
        Get ComStringOf Of hoJsonResponse "value[i].customerid_account.name" To sCustomerid_accountName
        Move i + 1 To i
    Loop



End_Procedure

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