0

I have a RestSharp code that work very well in V106. I want to convert it to the new RestSharp V108. I have converted all the code but i am stuck with the Request.AddHeader("Cookie", ".AspNetCore.Cookies="blablabla"). RestSharp V108 have removed the cookie in the header so how can i do it in RestSharp V108

Here my code from RestSharp V106:

var client = new RestClient("https://xx.xx.xx.xx/api/v2/users");
        client.RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;
        client.Timeout = -1;
        var request = new RestRequest(Method.GET);
        request.AddHeader("Authorization", "Basic usernamepassword=");
        request.AddHeader("Cookie", ".AspNetCore.Cookies="bunchofletterandnumber"
        var body = @"";
        request.AddParameter("text/plain", body, ParameterType.RequestBody);
        IRestResponse response = client.Execute(request);

Here my Restsharp code in V108

var options = new RestClientOptions("https://XX.XX.XX.XX/api/v2/users")
        {
            ThrowOnAnyError = true,
            MaxTimeout = 1000,
            RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true,
        };
        var client = new RestClient(options);
        client.Authenticator = new HttpBasicAuthenticator("username", "password");
        var request = new RestRequest("https://xx.xx.xx.xx/api/v2/users", Method.Get);
        RestResponse response = await client.ExecuteAsync(request);         
        

0 Answers0