Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Performing updates using alternate key in Dynamics 365 WebAPI

(0) ShareShare
ReportReport
Posted on by 25

Can anyone help , as I believe someone has already faced the issue I'm having.

I have a custom entity (alssc_anglesector) with an alternate key (alssc_name)

“alssc_ANGLESector@odata.bind”: “/alssc_anglesectors(alssc_name=’Air’)”, “

alssc_ANGLESector@odata.bind”: “/alssc_anglesectors(alssc_name=’Water Auth/Company’)”,

when I create an account and use the first bind with “Air” it works fine, while when using the second “Auth/Company” I got the response

“message”: “Bad Request – Error in query syntax.”, “type”: “Microsoft.OData.ODataException”, “stacktrace”: ” at Microsoft.OData.UriParser.ODataPathParser.ExtractSegmentIdentifierAndParenthesisExpression(String segmentText, String& identifier, String& parenthesisExpression)

I have also tried to encode it

"alssc_ANGLESector@odata.bind": "/alssc_anglesectors(alssc_name=\u0027Water Auth\u002FCompany\u0027)",

but he end result was the same.

I’m not being able to overcome this, Any ideias / suggestions ?

Could it be a Bug in D365 API WebApi ?

Best regards, Manuel

  • Verified answer
    Alejandro Serdan Profile Picture
    on at
    RE: Performing updates using alternate key in Dynamics 365 WebAPI

    Hi!

    The request is unsupported: 

    Unicode characters in key value

    If the data within a field that is used in an alternate key will contain one of the following characters <,>,*,%,&,:,/,\\ then update or upsert (PATCH) actions will not work.

    If you only need uniqueness then this approach will work, but if you need to use these keys as part of data integration then it is best to create the key on fields that won't have data with these characters.

    https://docs.microsoft.com/en-us/powerapps/maker/common-data-service/define-alternate-keys-reference-records#unicode-characters-in-key-value

  • mesteves Profile Picture
    25 on at
    RE: Performing updates using alternate key in Dynamics 365 WebAPI

    Hi Bipin Kumar

    Thanks for the suggestion. The same reply is returned...

    "alssc_AcmeSector@odata.bind""/alssc_Acmesectors(alssc_name='Water%20Auth%2FCompany')",
    "innererror": {
                "message""Bad Request - Error in query syntax.",
                "type""Microsoft.OData.ODataException",
                "stacktrace""   at Microsoft.OData.UriParser.ODataPathParser.ExtractSegmentIdentifierAndParenthesisExpression
    I'll customize the entities with one extra column (code) and will  go that way... but this seems to be some sort of bug in the Api....
    Thanks,
    Manuel
  • Suggested answer
    Bipin D365 Profile Picture
    28,981 Moderator on at
    RE: Performing updates using alternate key in Dynamics 365 WebAPI

    Hi,

    Can you try below syntax and see if it works.

    Water%20Auth%2FCompany

    If found helpful, Please mark my answer verified.

  • mesteves Profile Picture
    25 on at
    RE: Performing updates using alternate key in Dynamics 365 WebAPI

    Thanks Aditya ,

    However in a integration scenario with external applications, it harder to do it by Id, we would need to know all the possible values for the Id's.

    Thanks anyway, it's an option to keep open :) 

  • Suggested answer
    Aditya Profile Picture
    260 on at
    RE: Performing updates using alternate key in Dynamics 365 WebAPI

    Hi Mesteves,

    I am not sure how alternate keys are assigned in D365

    but I know that @odata.bind can be used for the record id as shown below :-

         var data={         "alssc_anglesectorid@odata.bind": "/alssc_anglesectors(" + result[_alssc_anglesectorid_value] + ")"}

    or

    newObj["alssc_anglesectorid@odata.bind"] = "/alssc_anglesectors(" + result["_alssc_anglesectorid_value"] + ")";

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Performing updates using alternate key in Dynamics 365 WebAPI

    Manuel,

    The best way is to open a ticket with Microsoft and ask for support - mbs.microsoft.com/.../CRMSupport

  • mesteves Profile Picture
    25 on at
    RE: Performing updates using alternate key in Dynamics 365 WebAPI

    Thanks a33ik,

    I have tried, and the result is the same :( 

    "alssc_ANGLESector@odata.bind": "/alssc_anglesectors(alssc_name='Water Auth%2fCompany')",
    "message": "Bad Request - Error in query syntax.",

    I'm starting to really believe that is a webApi issue. How can I have someone from MSFT to take a look and confirm this problem ? 

    Best regards, 

    Manuel

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Performing updates using alternate key in Dynamics 365 WebAPI

    Hello,

    Try to replace 

    ’Water Auth/Company’

    with 

    ’Water Auth%2fCompany’

    according to following post - https://stackoverflow.com/questions/43139878/webapi-with-backslash-2f-in-id-parameter-causes-404-not-found

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 106

#3
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 82 Super User 2025 Season 1

Overall leaderboard

Product updates

Dynamics 365 release plans