Skip to content
Advertisement

Python – Dynamics CRM Web API – SuppressDuplicateDetection Not working

I am running into an issue with the ability to Suppress Duplicate Detection in the Dynamics CRM API. I am qualifying leads and the Duplicate Detection is getting triggered on some of the leads. I have some logic to decide if we want to suppress the so on certain leads I want to bypass that detection.

What is happening is it is not working when in the request headers I set the MSCRM.SuppressDuplicateDetection: true and it will still not qualify the lead.

Here is my full code:

    api_surpress_dup_detection_headers = {
    "Authorization": BEARER,
    "If-None-Match": None,
    "OData-Version": "4.0",
    "OData-MaxVersion": "4.0",
    "Content-Type": "application/json",
    "Accept": "application/json",
    "MSCRM.SuppressDuplicateDetection": "true",
    "If-Match": "*"
}

lead_qualify_url = f"{data_url}leads({lead_guid})/Microsoft.Dynamics.CRM.QualifyLead"
data = {
    'CreateAccount': False,
    'CreateContact': True,
    'CreateOpportunity':False,
    'Status':3
}
qualify_lead_response = requests.post(lead_qualify_url, headers=api_surpress_dup_detection_headers, data=json.dumps(data))

The result I get is:

<Response [412]> ‘{“error”:{“code”:”0x80040333″,”message”:”A record was not created or updated because a duplicate of the current record already exists.”}}’

If anyone has solved this before I would greatly appreciate any help!

Advertisement

Answer

From documentation, I see that adding MSCRM.SuppressDuplicateDetection in request header works for CREATE and UPDATE request.

For QualifyLead action – this may be little different. Instead of adding request header – you may need to include in payload like explained in this blog.

this.SuppressDuplicateDetection = true  // or false

"SuppressDuplicateDetection": {
     "typeName": "Edm.Boolean", "structuralProperty": 1
 }
Advertisement