question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RestResponseCookie is not interchangeable with System.Net.Cookie

See original GitHub issue

Expected Behavior

Consider this code

var client = new RestClient("https://example.com/api");
var loginRequest = new RestRequest("Login", Method.POST);
var result = client.Execute(loginRequest ); // has a Set-Cookie: SessionID blablabla

//add the session cookie to the client for all further requests
foreach(var cookie in result.Cookies){
        client.CookieContainer.Add(cookie) //<-- Type Error
}

Actual Behavior

Error: cannot convert "RestSharp.RestResponseCookie" to "System.Net.Cookie"

Is there a good reason to have a RestResponseCookie (which looks like copied from System.Net.Cookie, all fields are the same) and use it over the standard class? Otherwise this looks like a minor design flaw

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:29 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
GieltjEcommented, Jun 2, 2021

damn bot should be sent to /dev/null

0reactions
alexeyzimarevcommented, Dec 13, 2021

I removed HttpCookie entirely in v107. However, cookies were always accessible directly via the cookie container, you should always use one as you’d do with HttpClient.

The pre-release package is out there, feel free to test it. If you get any issues with cookies, please open another issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fixing obsolete warning of RestResponseCookie
I have a project that is using RestResponseCookie, it is showing me a warning ... The only way to fix the warning is...
Read more >
RestSharp Next (v107+)
It's because cookies are added to the HttpMessageHandler cookie container, which is not accessible inside the request class. var request = new RestRequest()...
Read more >
Saving Cookies from RestResponse or Passing Session IDs
I have written a c# code using RestSharp library to interact with RightScale API. The code works fine with one set of username...
Read more >
Attach file to post using C# RestSharp and Drupal Services
I have figured it out this way, sorry for late posting the answer: // FIRST LOGIN var client = new RestClient("http://.
Read more >
C# (CSharp) RestSharp RestClient.Execute Examples
AddBody(template); var response = client.Execute(request) as RestResponse; if (response.StatusCode.Equals(System.Net.HttpStatusCode.Created)) Response.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found