2

I know that similar questions have been already posted in the past but I read a lot on the subject and still couldn't find an answer to my problem. I have a GET request that works fine on Postman:

enter image description here

I translated it with the Code tool in C# - RestSharp and tested it with my plugin but somehow I always get the same error:

enter image description here

My C# - RestSharp code (It's the one I get with the Postman translator):

var client = new RestClient("https://..........."); //my url
     client.Timeout = -1;
     var request = new RestRequest(Method.GET);
     request.AddHeader("Cookie", ".........."); //my cookie
     IRestResponse response = client.Execute(request);

I tried adding all the headers visible in the Headers section:

request.AddHeader("User-Agent", "PostmanRuntime/7.29.0");
     request.AddHeader("Accept", "*/*");
     request.AddHeader("Accept-Encoding", "gzip, deflate, br");
     request.AddHeader("Connection", "keep-alive");

without result. The Authorization type is No Auth. Any idea? Maybe it has something to do with the fact that the response body in Postman is a plain text? The other requests I send that have a JSON response works perfectly fine.

Thank you for your help!

Christian Baumann
  • 3,188
  • 3
  • 20
  • 37
Paslet87
  • 87
  • 6
  • 1
    Try request.AddCookie method? – daveBM May 01 '22 at 15:34
  • 1
    @daveBM I've tried anything but not this. Thank you very much, it works pretty well with AddCookie method! Please, post an answer so I can accept it as the solution. – Paslet87 May 01 '22 at 15:43

1 Answers1

2

Use request.AddCookie(cookiename, cookievalue);

daveBM
  • 344
  • 1
  • 10