Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please provide any solution for consuming Kerberos enabled service using C# HttpClient

What I have tried:

I tried below code and getting error like "Authorization header is missing".


var response = Task.Run(async () => await xApiRequest.GetRequestAsync(apiUrl)).Result;
Console.WriteLine(response.DocFastUserId);


public async Task GetRequestAsync(string url)
{
try
{
var correlationId = Guid.NewGuid().ToString();
using (HttpClient httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.Add("x-correlation_id", correlationId);

using (HttpResponseMessage response = httpClient.GetAsync(url).Result)
{
using (HttpContent content = response.Content)
{
var json = await content.ReadAsStringAsync();
Console.WriteLine(json);
return JsonConvert.DeserializeObject(json);

}
}
}
}
catch
{
throw;
}
}
Posted
Updated 18-Nov-20 22:30pm

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900