I am doing a web api integration test.
I want to pass the carrier token to the Http request header:
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "eJ43k5l435j34l5j43l5j34l5jl35j34l5j344l.4534535.534534sample...");
When this line of code is executed, I look at the httpClient.DefaultRequestHeaders.Authorization property and is it NULL?
Why is this?
UPDATE
This is from the base class of my integration test class:
protected HttpClient Client { get { return server.HttpClient; } }
When I manually update the http client in the test class:
var client = new HttpClient(); client.DefaultRequestHeaders.Add("key","value");
It works, but not with my client !?
UPDATE 2
OK I found this:
var c = Client; c.DefaultRequestHeaders.Add("bla", "bla");
IT WORKS, but why should I read my client in a new variable?
asp.net-web-api asp.net-web-api2
Pascal
source share