2

I have a winrt app and a Windows.Web.Http.HttpClient

I want to set its Authorization header without using a scheme. My code is as below.

HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new HttpCredentialsHeaderValue("Scheme", "mytoken");

This will result in this Authorization: Scheme mytoken

What I want is this Authorization: mytoken

The problem is that the Constuctor of HttpCredentialsHeaderValue has to take a scheme argument and that scheme cannot be String.empty

Is there a way I can achieve this result?

2
  • 1
    stackoverflow.com/a/11420667/95190 Your format isn't valid per spec. Can you change the server? Commented Sep 11, 2015 at 10:46
  • Thanks for your answer @WiredPrairie . I understand why the HttpClient works that way now. However the server is beyond my control. Do you know of a way to format the Authorization header ommiting the scheme? Commented Sep 11, 2015 at 14:33

1 Answer 1

4

Try:

HttpClient client = new HttpClient();
client.DefaultRequestHeaders.TryAppendWithoutValidation(
    "Authorization",
     "mytoken");
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.