0

im using restsharp to send requests to https://httpbin.org/post but the only thing i get back is StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: <null>, Headers: { } how do i get the headers?

my code:

  var options = new RestClientOptions("https://api.mail.tm/accounts")
            {
                Proxy = GetWebProxy(),
                ThrowOnAnyError = true,
                Timeout = 10000
            };
            var client = new RestClient(options);
            var request = new RestRequest();
            var body = new post { address = name + number +"@cutradition.com", password = "password" };
            request.AddJsonBody(body);
           var response = await client.PostAsync<HttpResponseMessage>(request);

           Console.WriteLine(response);

       Console.WriteLine(response);

if you know how to get the headers please tell me

waaffleman420
  • 21
  • 1
  • 3

1 Answers1

0

PostAsync<HttpResponseMessage> makes no sense as RestSharp will try to deserialize the response to HttpRequestMessage, and it is not something I would expect from your server.

I strongly suggest reading the documentation.

If you change your code to this:

var response = await client.ExecutePostAsync(request);

you will get all the headers and the response content inside the response object.

Alexey Zimarev
  • 17,944
  • 2
  • 55
  • 83