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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)
Answered

How to avoid duplicates when creating records using Web API (C#) ?

(0) ShareShare
ReportReport
Posted on by 6

When I try to create a duplicate in the CRM web application I am getting a pop-up indicating that I am trying to create a duplicate record. However, if the create using Web API (C#) from a .Net application then by default, the duplicate record is getting created without any warning.

Here is the sample code we are using to using to create a record using Web API

 JObject accountRecord = new JObject();
            accountRecord.Add("name", "JKC");
            accountRecord.Add("accountnumber", "00112233");

            HttpRequestMessage createAccountReq =
               new HttpRequestMessage(HttpMethod.Post, getVersionedWebAPIPath() + "accounts");

            createAccountReq.Content = new StringContent(accountRecord.ToString(),
                Encoding.UTF8, "application/json");

            HttpResponseMessage createAccountRes =
                await httpClient.SendAsync(createAccountReq);


*This post is locked for comments

I have the same question (0)
  • Verified answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    if you want to avoid duplicates create an alternate key connected to your unique attribute

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    To turn on duplicates validation using webapi you should add new header "MSCRM.SuppressDuplicateDetection" to request with value "false".

    That should resolve your ussue.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans