How do i Consume Rest Webservice data by HttpWebRequest/WebClient using Headers?
Here is my code:-
using (var clients = new HttpClient())
{
//clients.DefaultRequestHeaders.UserAgent.ParseAdd(UserAgent);
var a = "mywebserviceurl"+ "AbsenceOdata";
var requests = new HttpRequestMessage()
{
RequestUri = new Uri(a),
Method = HttpMethod.Get,
};
//requests.Headers.Add("Content-Type", "application/xml");
requests.Headers.Add("X-SMP-APPCID", "84004aa6-554b-47cb-b9a9-1c9fc8874cd8");
requests.Headers.Add("X-CSRF-Token", "FETCH");
var responseMessage = await clients.SendAsync(requests);
var responses = await responseMessage.Content.ReadAsStringAsync();
var json = await clients.GetStringAsync(requests.RequestUri);
if (responseMessage.IsSuccessStatusCode)
{
var jObject = JObject.Parse(responses);
var r = JsonConvert.DeserializeObject<ArrayOfAbsenceDTO>(jObject.ToString());
}
}