odata.net
odata.net copied to clipboard
Odata client on iOS throws An item with the same key has already been added. Key: OData-Version error
I've got a shared client library with an OData connected service being run in a blazor app. When it's run in a web project or on Android it works fine; however, when running on maui hybrid on iOS I get the error in the title. I'm adding an Authorization header, but not doing anything else to the headers. I've tried setting that header to null before I get the error to no avail. Edit- I just found out that the error only happens when I've got the HttpRequsetTransportMode is HttpClient. I don't get this error with HttpWebRequest. Other considerations are forcing me to use Client elsewhere.
"An item with the same key has already been added. Key: OData-Version"
" at Microsoft.OData.Client.BaseAsyncResult.EndExecute[QueryResult](Object source, String method, IAsyncResult asyncResult)\n at Microsoft.OData.Client.QueryResult.EndExecuteQuery[Appointment](Object source, String method, IAsyncResult asyncResult)\n at Microsoft.OData.Client.DataServiceRequest.EndExecute[Appointment](Object source, DataServiceContext context, String method, IAsyncResult asyncResult)\n at Microsoft.OData.Client.DataServiceQuery1[[BackOfficeScheduler.Data.Appointment, BackOfficeScheduler.BO, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].EndExecute(IAsyncResult asyncResult)\n at System.Threading.Tasks.TaskFactory1[[System.Collections.Generic.IEnumerable1[[BackOfficeScheduler.Data.Appointment, BackOfficeScheduler.BO, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task1 promise, Boolean requiresSynchronization)\n--- End of stack trace from previous location ---\n at BackOfficeScheduler.Web.Pages.Pages.Dashboard.OnInitializedAsync() in"
Assemblies affected
OData .Net lib 7
Reproduce steps
Consume a connected OData service from an iOS maui blazor app
Expected result
Requests are made successfully
Actual result
OData connected service is adding the OData header more than once.
Has a solution or workaround been found for this problem? I am having this problem right now since the 8.0.0 release.
Hi,
I have got past this, but honestly I can't remmeber what I did. If you'd care to hire me out for an hour or two to remember, please let me know.
It has taken a few months, but I have found a solution. I have posted it in this post: https://github.com/xamarin/xamarin-macios/issues/17331#issuecomment-2575685911