I'm using
var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://test.net");
To create a connection to the server and would like to know how I can add headers to httpWebRequest
?
I'm using
var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://test.net");
To create a connection to the server and would like to know how I can add headers to httpWebRequest
?
Examples:
HttpClient:
client.DefaultRequestHeaders.Accept
.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "xxxxxxxxxxxxxxxxxxxx");
using webRequest:
webRequest.Headers.Add("Authorization", "Basic dchZ2VudDM6cGFdGVzC5zc3dvmQ=");