web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Unanswered

How to add a Case/Incident with CustomerId and ContactId using Rest api

(0) ShareShare
ReportReport
Posted on by 40

HI EXpert,

  I want to add case/Incident  with CustomerId and ContactId using Rest api oAuth2. I am able add incident without CustomerId and ContactId. I am trying add data using below formats but getting error for all :

pastedimage1614689729959v1.png

https://insyncsolutions.crm8.dynamics.com/api/data/v9.0/incidents

Body Sample1 :

{
"_customerid_value": "89d10845-a0a1-ea11-a812-000d3a0a8282",
"title": "{#33613}: Ishaan-Pooja Twilio Test",
"_primarycontactid_value": "7b4e4434-bc2f-eb11-a813-000d3a0a8282"
}

Body Sample2:

{
"customerid_accountcustomerid_contact@odata.bind": "89d10845-a0a1-ea11-a812-000d3a0a8282",

"title": "{#33616}: Ishaan-Pooja Twilio Test",
"primarycontactid@odata.bind":"/contacts(7b4e4434-bc2f-eb11-a813-000d3a0a8282)"
}

Body Sample3 :

{
"customerid_contact@odata.bind": "/contacts(7b4e4434-bc2f-eb11-a813-000d3a0a8282)",
"title": "{#33616}: Ishaan-Pooja Twilio Test",
"primarycontactid@odata.bind":"/contacts(7b4e4434-bc2f-eb11-a813-000d3a0a8282)"
}

Please suggest how can i add incident with CustomerId and ContactId using Rest api oAuth2.

Thanks

Surajit Kundu

  • Community Member Profile Picture
    on at

    Hi surajitinsync,

    This may not be an error in the code itself, this error may be in the logic of the case.

    There is a certain logical relationship between the Customer field and the Contact field.

    1.If I select one account in customer field, the contact field just can fill child contacts that related to the selected account.

    Account: A. Datum Corporation (sample) has three child contacts.

    pastedimage1614235979996v1.png

    The contact field just show these three contacts.

    pastedimage1614236031929v2.png

    For testing, If i choose one contact that not related to the account in recent contacts, it will show error.

    pastedimage1614236180203v3.png

     2.If I select one contact in customer field, the contact field can’t be filled with any value.

    One Contact:Abraham McCormick, no results show in the contact field.

     pastedimage1614236385098v4.png

    For testing, If i choose one contact that not related to the account in recent contacts, it will show error.

    pastedimage1614236592054v5.png

    So you must follow the rules above to select customer and contact when you create case with customer and contact.

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • surajitinsync Profile Picture
    40 on at

    HI Lea ,

     Thanks for your reply . I think i am following the rule as i am able add from UI.  I have created a case manually  with Customer and Contact link. In postman i get that  Case/Incident . Using that that get structure i am trying to post same type of structure for Customer and Contact.

    Below is my Get structure :

       "value": [

           {

               "@odata.etag": "W/\"82093082\"",

               "statecode": 0,

               "resolvebyslastatus": 1,

               "statuscode": 100000000,

               "createdon": "2021-02-24T11:16:16Z",

               "_customerid_value": "89d10845-a0a1-ea11-a812-000d3a0a8282",

               "ticketnumber": "CAS-04765-Z5F2F4",

                 "crf50_lastnotificationsenton": "2021-02-24T11:26:08Z",

               "adx_publishtoweb": false,

               "severitycode": 1,

               "_ownerid_value": "31bb1a1c-0d91-ea11-a811-000d3a0a8315",

               "servicestage": 0,

               "modifiedon": "2021-02-24T11:26:08Z",

               "title": "{#33612}: Ishaan-Pooja Twilio Test",

               "decremententitlementterm": true,

               "prioritycode": 2,

               "crf50_basetitle": "Ishaan-Pooja Twilio Test",

               "timezoneruleversionnumber": 0,

               "blockedprofile": false,

               "crf50_caseid": "33612",

               "_modifiedby_value": "59bb1a1c-0d91-ea11-a811-000d3a0a8315",

               "caseorigincode": 100000000,

               "isdecrementing": false,

               "firstresponseslastatus": 1,

               "_primarycontactid_value": "7b4e4434-bc2f-eb11-a813-000d3a0a8282"

    }

    ]

    1) I am getting error below  when send attribute as customerid_accountcustomerid_contact@odata.bind  and primarycontactid@odata.bind


    "error": {
    "code": "0x0",
    "message": "An error occurred while validating input parameters: Microsoft.OData.ODataException: An undeclared property 'customerid_accountcustomerid_contact' which only has property annotations in the payload but no property value was found in the payload. In OData, only declared navigation properties and declared named streams can be represented as properties without values.\r\n at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadUndeclaredProperty(IODataJsonLightReaderResourceState resourceState, String propertyName, Boolean propertyWithValue)\r\n at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadPropertyWithoutValue(IODataJsonLightReaderResourceState resourceState, String propertyName)\r\n at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.<>c__DisplayClass9_0.<ReadResourceContent>b__0(PropertyParsingResult propertyParsingResult, String propertyName)\r\n at Microsoft.OData.JsonLight.ODataJsonLightDeserializer.ProcessProperty(PropertyAndAnnotationCollector propertyAndAnnotationCollector, Func`2 readPropertyAnnotationValue, Action`2 handleProperty)\r\n at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadResourceContent(IODataJsonLightReaderResourceState resourceState)\r\n at Microsoft.OData.JsonLight.ODataJsonLightReader.StartReadingResource()\r\n at Microsoft.OData.JsonLight.ODataJsonLightReader.ReadResourceSetItemStart(PropertyAndAnnotationCollector propertyAndAnnotationCollector, SelectedPropertiesNode selectedProperties)\r\n at Microsoft.OData.JsonLight.ODataJsonLightReader.ReadAtStartImplementationSynchronously(PropertyAndAnnotationCollector propertyAndAnnotationCollector)\r\n at Microsoft.OData.ODataReaderCore.ReadImplementation()\r\n at Microsoft.OData.ODataReaderCore.InterceptException[T](Func`1 action)\r\n at System.Web.OData.Formatter.Deserialization.ODataReaderExtensions.ReadResourceOrResourceSet(ODataReader reader)\r\n at System.Web.OData.Formatter.Deserialization.ODataResourceDeserializer.Read(ODataMessageReader messageReader, Type type, ODataDeserializerContext readContext)\r\n at System.Web.OData.Formatter.ODataMediaTypeFormatter.ReadFromStream(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger)"
    }

    2)  when send data as  "_customerid_value": "89d10845-a0a1-ea11-a812-000d3a0a8282"   "_primarycontactid_value": "7b4e4434-bc2f-eb11-a813-000d3a0a8282"

         "error": {
    "code": "0x0",
    "message": "CRM do not support direct update of Entity Reference properties, Use Navigation properties instead."

    I can't understand what will be exact format for above two fileds.

    Thanks

    Surajit

  • surajitinsync Profile Picture
    40 on at

    Hi All ,

     After my try and error i have successfully post the data with Customer (account) and Contact with below format :

      insyncsolutions.crm8.dynamics.com/.../incidents

      {

       "title": "{#33615}: surajit Twilio Test new 4",

       "customerid_account@odata.bind": "/accounts(89d10845-a0a1-ea11-a812-000d3a0a8282)",

        "primarycontactid@odata.bind": "/contacts(7b4e4434-bc2f-eb11-a813-000d3a0a8282)"

      }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Syed Aqib Raza Profile Picture

Syed Aqib Raza 42

#2
11manish Profile Picture

11manish 33 Super User 2026 Season 2

#2
Travis South Profile Picture

Travis South 33

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans