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

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

Strange behavior of the RetrieveDuplicate WebApi

(1) ShareShare
ReportReport
Posted on by 9
After various difficulties, requests to the RetrieveDuplicates WebAPI finally work ... at least in principle.
For example, this request runs without errors and returns either an empty array or duplicates, if there are any:
 
https://<URL>/api/data/v9.2/RetrieveDuplicates(MatchingEntityName='account',BusinessEntity=@BE,PagingInfo=@PI)?@BE={"@odata.type":"Microsoft.Dynamics.CRM.account","name":"ABC (123)"}&@PI={"Count":10,"PageNumber":1,"PagingCookie":null}
 
But as soon as the requested account name is like "ABC (123) X" I get a BAD REQUEST error. What are I'm doing wrong, or is it a bug in the WebAPI?
 
 
Interestingly one of my first difficulties with this API was that I got BAD REQUEST but only if the account name contains brackets. Later I figured out, that the order of the json values of the business entity parameter matters.
While
@BE={"@odata.type":"Microsoft.Dynamics.CRM.account","name":"ABC (123)"}
was working,
@BE={"name":"ABC (123)","@odata.type":"Microsoft.Dynamics.CRM.account"}
did not.
 
Now, with the "correct" order of the entity values, the request is still failing, if the account name has more characters after the closing bracket and I have no clue what to try next.
Any help is greatly appreciated, even a statement that this is a bug in the API would be of help, obviously.
 
I have the same question (1)
  • PC-22091458-0 Profile Picture
    4 on at
    Strange behavior of the RetrieveDuplicate WebApi
    Try:

    @BE={"@odata.type":"#Microsoft.Dynamics.CRM.account","name":"ABC (123)"}
     
    Just encountered this and noticed that the OOTB calls have a # prefixing the custom data type.  
    That resolved the issue for me.
  • Ray Profile Picture
    1,537 on at
    Strange behavior of the RetrieveDuplicate WebApi
    Hi Danny,
     
    Firs of all, the nuget package should be Microsoft.CrmSdk.CoreAssemblies. This is the standard SDK package for Plugin, Custom Action and Custom API.

    And I think you can use following workarounds:
    1. Query the duplicate records directly with account name(also can be fetchxml): https://yourorg.crm.dynamics.com/api/data/v9.2/accounts?$filter=name eq 'ABC%20%28123%29%20X'.
    2. Create a Custom API, this Custom API execute the RetrieveDuplicatesRequest with request data, so you do have to worry the encode and the Custom API is RESTful.
     
    I also gathered the ​​​​​​​RetrieveDuplicatesRequest http request with Fiddler, it is XML format, so it has no issue with character encode:
    ​​​​​​​
     
  • Danny Profile Picture
    9 on at
    Strange behavior of the RetrieveDuplicate WebApi
    So I tried the request utilizing the Microsoft.Crm.Sdk.Messages.RetrieveDuplicatesRequest with the Microsoft.PowerPlatform.Dataverse.Client.ServiceClient.
    This time the request worked as expected and the duplicates were returned. But including that NuGet package is actually not the solution for me. I still nned to do this request using the RESTful API.
     
  • Danny Profile Picture
    9 on at
    Strange behavior of the RetrieveDuplicate WebApi
    Hi Ray,
    I posted the URL and thus the request parameters without any encoding for better readability... sorry for not mentioning this in the first place. But of course I do send it url-encoded, so yes blanks are replaced by %20 (or a + sign depending on encoding mechanism). I have no difficulties to get a decent response when the name  contains parentheses as long as there comes nothing after the ). And yes replacing ( and ) by %28 and %29 does not solve the problem. 
    Plus.. for an account name like "ABC DEF (XYZ)" it's sufficient to send "ABC%20DEF%20(XYZ)" for me to get a valid response, so actually the parentheses don't have to be replaced.
    But you where saying the RetrieveDuplicatesRequest is working? That's the class provided in the SDK, right? Okay, than I should try this and try to figure out what that is sending to the servers endpoint.
  • Ray Profile Picture
    1,537 on at
    Strange behavior of the RetrieveDuplicate WebApi
    Have you tried a query without space and parenthes? Like "name":"ABCX".
    I think the issue is caused by the special character " ","(" and ")". The " " should be replaced with "%20". But I am unable to get a result if query has "(", even after replaced "(" with "%28".
    Also you can try with backend request RetrieveDuplicatesRequest. This works fine per my test.
     

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daniyal Khaleel Profile Picture

Daniyal Khaleel 208

#2
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 182

#3
Tom_Gioielli Profile Picture

Tom_Gioielli 77 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans