Hello,
If you send a request through Postman and check the response, there is a tab called Headers.
That's what I need to retrieve. For debugging, I want to get a custom header called TransactionID. I want to get the header with the response I'm receiving from the server.
This is my code and I want to save the headers of the response.
How can I do this?
var client = new RestClient(ConfigurationManager.AppSettings["base_url"]);
client.Timeout = -1;
var request = new RestRequest(Method.POST);
var authenticationString = string.Format("{0}:{1}", ConfigurationManager.AppSettings["User"], ConfigurationManager.AppSettings["Password"]);
var base64EncodedAuthenticationString = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(authenticationString));
request.AddHeader("Authorization", "Basic " + base64EncodedAuthenticationString);
request.AddHeader("Content-Type", "application/xml");
var body = @"<Testing>"
+ "\n" + @" <var1>var</var1>"
+ "\n" + @"</Testing>";
request.AddParameter("application/xml", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);