You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Problem with RestSharp on MAUI on iOS platform #1984
To Reproduce
I try run app on iOS local device. And Unfortunately I have this error:
[0:] An error occurred: 'Operation is not supported on this platform.'. Callstack: ' at System.Net.Http.NSUrlSessionHandler.set_Proxy(IWebProxy value)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
--- End of stack trace from previous location ---
at System.Net.Http.HttpClientHandler.InvokeNativeHandlerMethod(String name, Object[] parameters)
at System.Net.Http.HttpClientHandler.SetProxy(IWebProxy value)
at System.Net.Http.HttpClientHandler.set_Proxy(IWebProxy value)
at RestSharp.RestClient.ConfigureHttpMessageHandler(HttpClientHandler handler)
at RestSharp.RestClient..ctor(RestClientOptions options, Action`1 configureDefaultHeaders)
at RestSharp.RestClient..ctor(Uri baseUrl)
at RestSharp.RestClient..ctor(String baseUrl)
Expected behavior
App should run.
Desktop:
OS: Windows
Visual Studio Enterprise 2022 Preview 17.5.0 Preview 2.0
Version 7.0.101
App version: .NET 6
I try run on iOS platform on local device
Hi @alexeyzimarev, the issue is not just maui related. It is net6-ios related. The problem is that setting the proxy on a NSUrlSessionHandler causes a PlatformNotSupportedException
The Code looks like var client = new RestClient("test")
and because of if (handler.SupportsProxy) handler.Proxy = Options.Proxy;
in ConfigureHttpMessageHandler in RestClient it throws the exception.
Activity
alexeyzimarev commentedon Dec 14, 2022
You need to at least provide your code and the version of RestSharp.
Larhei commentedon Jan 30, 2023
Hi @alexeyzimarev, the issue is not just maui related. It is net6-ios related. The problem is that setting the proxy on a
NSUrlSessionHandler causes a PlatformNotSupportedException
The Code looks like
var client = new RestClient("test")and because of
if (handler.SupportsProxy) handler.Proxy = Options.Proxy;in ConfigureHttpMessageHandler in RestClient it throws the exception.
I'm on Version 108.0.3.