Open kgorking opened 1 year ago
I have the same issue. For exceptions occurring during a request executed via DataServiceQuery class, I have the same error. I think the WebException class should not be used inside the HttpClientRequestMessage class
I get the same exception when using Blazor Wasm. I narrowed it down to the same line as identified by @kgorking. If you accept PRs, what would be an appropriate Exception here?
I get the same exception when using Blazor Wasm. I narrowed it down to the same line as identified by @kgorking. If you accept PRs, what would be an appropriate Exception here?
Exception raised by HttpClient are HttpRequestException (https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httprequestexception?view=net-7.0). So, I think this should be more appropriate class to use
It’s not relevant to the issue, but I think it’s quite an undertaking to make this client compatible to Blazor WASM and not introduce breaking changes. I have used Kiota instead, which generates a nice client, that also works with Blazor WASM: https://www.bytefish.de/blog/odata_openapi_kiota_client_generation.html
I'm writing a Blazor webapp using SAP B1 through OData, and using
serviceLayer.HttpRequestTransportMode = HttpRequestTransportMode.HttpClient
so it can work in a wasm environment. It seems something unsupported slipped through, however.System.Net.Requests is not supported on this platform
is triggered on calls toDataServiceQuery.ExecuteAsync()
.If I use the code from Use HttpClient in OData Client, the call works fine and the data returned correctly.
Assemblies affected
OData client 7.0.5
Reproduce steps
The exception is triggered by a cors failure, due to the insertion of 'odata-(max)version)' headers which I didn't have allowed. Doing the exact same request manually using a
HttpClient.SendAsync()
works fine and returns the requested data.Expected result
Requested data is returned.
Actual result
An exception is raised due to use of unsupported code.
Additional detail
I am hitting the following exception
which seems to be triggered on the following line of code https://github.com/OData/odata.net/blob/30f4e3aaecafa8554f20a62a755e7875aab7c88c/src/Microsoft.OData.Client/Serialization/HttpClientRequestMessage.cs#L473