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...
Suggested Answer

Creating Incident From WEB API via API in C#

(0) ShareShare
ReportReport
Posted on by 1,415

I am trying to create a case in c# via web api & I am able to create contacts and other entities records so authentication is not an issue.

I am using below code and getting bad request 400 not sure why. Please advice.

 JObject caseObj = new JObject();

 caseObj.Add("customerid_contact@odata.bind", "/contacts(164a650d-06b3-ea11-a812-000d3af0247a)");

 caseObj.Add("title", "New Case");

var accessToken = await GetAccessToken();


var client = new HttpClient();
var message = new HttpRequestMessage(HttpMethod.Post,   orgUrl + "https://abc.api.crm8.dynamics.com/api/data/v9.1/" +  "incidents" );

message.Headers.Add("OData-MaxVersion", "4.0");
message.Headers.Add("OData-Version", "4.0");
message.Headers.Add("Prefer", "odata.include-annotations=*");
message.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);

message.Content = new StringContent(caseObj.ToString(), UnicodeEncoding.UTF8, "application/json");

// Send the message to the WebAPI.
var response = await client.SendAsync(message);

In response getting bad request 400.

Thanks,

Deepak

  • Suggested answer
    Denny Deng Profile Picture
    Microsoft Employee on at

    please check if 'customerid_contact' is collection-valued navigation property

    Associating entities this way using a collection-valued (1:N or N:N) navigation property is not supported by the Web API.

    docs.microsoft.com/.../create-entity-web-api

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
Daniyal Khaleel Profile Picture

Daniyal Khaleel 58 Most Valuable Professional

#2
Travis South Profile Picture

Travis South 37

#3
11manish Profile Picture

11manish 22 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans