简体   繁体   中英

Performing updates using alternate key in Dynamics 365 WebAPI

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 the end result was the same.

I'm not being able to overcome this, Any ideas / suggestions?

could it be a Bug in D365 API WebApi?

As per the answer in the comment thread: This request is unsupported because it contains Unicode characters

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.

The suggestion from the Microsoft Docs is to create another field (such as a code, or a simplified name) that does not contain these characters

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

In this case you have to change 'Water Auth/Company' with 'Water Auth%2FCompany' because of '/' special character.

I hope it works.

Ugur

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM