Objective-C 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"

Objective-C Example

#import <CkoRest.h>
#import <CkoStringBuilder.h>
#import <CkoJsonObject.h>
#import <NSString.h>

CkoRest *rest = [[CkoRest alloc] init];
BOOL success;

//  URL: https://my-dynamics-domain.api.crm.dynamics.com/api/data/v9.0/incidents
BOOL bTls = YES;
int port = 443;
BOOL bAutoReconnect = YES;
success = [rest Connect: @"my-dynamics-domain.api.crm.dynamics.com" port: [NSNumber numberWithInt: port] tls: bTls autoReconnect: bAutoReconnect];
if (success != YES) {
    NSLog(@"%@%d",@"ConnectFailReason: ",[rest.ConnectFailReason intValue]);
    NSLog(@"%@",rest.LastErrorText);
    return;
}

[rest AddQueryParam: @"$expand" value: @"customerid_account($select=accountid,name)"];
[rest AddQueryParam: @"$filter" value: @"incidentid eq c49e62a8-90df-e311-9565-a45d36fc5fe8"];

[rest AddHeader: @"OData-MaxVersion" value: @"4.0"];
[rest AddHeader: @"Accept" value: @"application/json"];
[rest AddHeader: @"OData-Version" value: @"4.0"];
[rest AddHeader: @"Authorization" value: @"Bearer DYNAMICS_CRM_ACCESS_TOKEN"];

CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
success = [rest FullRequestNoBodySb: @"GET" uriPath: @"/api/data/v9.0/incidents" sb: sbResponseBody];
if (success != YES) {
    NSLog(@"%@",rest.LastErrorText);
    return;
}

int respStatusCode = [rest.ResponseStatusCode intValue];
if (respStatusCode >= 400) {
    NSLog(@"%@%d",@"Response Status Code = ",respStatusCode);
    NSLog(@"%@",@"Response Header:");
    NSLog(@"%@",rest.ResponseHeader);
    NSLog(@"%@",@"Response Body:");
    NSLog(@"%@",[sbResponseBody GetAsString]);
    return;
}

CkoJsonObject *jsonResponse = [[CkoJsonObject alloc] init];
[jsonResponse LoadSb: sbResponseBody];

int i;
int count_i;

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

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