Home > database >  GET request works on Postman but fail with RestSharp
GET request works on Postman but fail with RestSharp

Time:05-02

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!

CodePudding user response:

Use request.AddCookie(cookiename, cookievalue);

  • Related