• DSI Integration 6
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
I currently have a C# Web Application that is creating new Accounts in Salesforce using REST API. 

I would like to check for duplicates prior to creating the records using REST API. 

I recently discovered Sforce-Duplicate-Rule-Header (https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/headers_duplicaterules.htm). 

After adding the header to my HTTP Requests, I expected to receive a response with all fields in the duplicate record when the record being created is determined to be a duplicate based on my Duplicate Rules for Account Object.

Am I misinterpreting what this header is supposed to do for me?

HTTP Request (POST / Create for an Account that already exists):
Method: POST, RequestUri: 'https://XXXXX.my.salesforce.com/services/data/v52.0/sobjects/Account', Version: 1.1, Content: System.Net.Http.StringContent, Headers:
{
  Accept: application/json
  Authorization: Bearer XXXXX
  Sforce-Duplicate-Rule-Header: allowSave=false; includeRecordDetails=true; runAsCurrentUser=true
  Content-Type: application/json; charset=utf-8
},
Content:
{
  "Name":"Test Account",
  "First_Name__c":"Test",
  "Last_Name__c":"Account",
  "BillingStreet":"123 Main St",
  "BillingCity":"Pittsburgh",
  "BillingState":"PA",
  "BillingPostalCode":"12345",
  "Phone":"1234567890"
}
HTTP Response:
{
  "id":"XXXXX",
  "success":true,
  "errors":[]
}

Because the account already exists, I'd expect to get back all fields in the duplicate record.  At very least I'd expect something other than a successful creation. 

Am I misinterpretting what this header does or how to use it?