Skip to content

Problem with RestSharp on MAUI on iOS platform #1984

Closed

Description

@zuzannaczaja

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

Activity

  1. alexeyzimarev commented on Dec 14, 2022

    @alexeyzimarev
    Member

    You need to at least provide your code and the version of RestSharp.

  2. Larhei commented on Jan 30, 2023

    @Larhei

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions