mesteves
mesteves

Reputation: 438

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)

[email protected]”: “/alssc_anglesectors(alssc_name=’Air’)”,
“[email protected]”: “/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

"[email protected]": "/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 ?

Upvotes: 1

Views: 693

Answers (2)

jasonscript
jasonscript

Reputation: 6180

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://learn.microsoft.com/en-us/powerapps/maker/common-data-service/define-alternate-keys-reference-records#unicode-characters-in-key-value

Upvotes: 1

UgurBe
UgurBe

Reputation: 11

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

I hope it works.

Ugur

Upvotes: 0

Related Questions