microsoft / PowerPlatform-DataverseServiceClient

Code Replica for Microsoft.PowerPlatform.Dataverse.Client and supporting nuget packages.
MIT License
277 stars 50 forks source link

Inconsistent error message on Duplicate Detection while using ExecuteWebRequest #452

Open metjuperry opened 3 months ago

metjuperry commented 3 months ago

Hello!

We've ran into and inconsistency when it comes to error messages returned by ExecuteWebRequest, especially in the case of the request failing because of Duplicate detection via Alternate Key.

Here's an example of fail message using .Create()

image

image

Here's an example of the same request using .ExecuteWebRequest()

image

image

One thing to note is that this request actually falls into the Exception ex instead of HttpOperationException httpex branch.

I suspect the issue is here:

https://github.com/microsoft/PowerPlatform-DataverseServiceClient/blob/d78a53d4afbe72e924f09ddfda2a848d6528f0e3/src/GeneralTools/DataverseClient/Client/ConnectionService.cs#L2628

Using Fiddler to see the request that's being send, we can actually see that the request actually returns the correct error message

image

.. but the abstraction above works with LastError which is of type Exception, which is the reason we lose HttpOperationException.Response which is why we lose the metadata of the actual error.

Thank you.

metjuperry commented 3 weeks ago

@MattB-msft Any news on this issue? It's holding us back a bit.