HttpClient request quotations in header RRS feed

  • Question

  • I'm trying to make a POST request using Web.HttpClient (JavaScript)

        var uri = new Windows.Foundation.Uri(baseURL);
        var hc = new Web.HttpClient();
        var authHeader = "authSig=\"dsadsASD\", timestamp=\"123132\"";
        var request = new Web.HttpRequestMessage(Web.HttpMethod.post, uri);
        request.headers.insert("Authorization", authHeader);

    However this is setting the Authorization header to:

       authSig=dsadsASD, timestamp=123132

    instead of:

     authSig="dsadsASD", timestamp="123132"

    Any thoughts why? or how I can get around this?

    Saturday, April 12, 2014 7:27 PM


  • Your authHeader needs a scheme (like "Basic", only that doesn't seem to be the scheme you're using.

    The answer is: because for the values you've got, you don't need the quotes.  If you add a space into the data -- like "authSiv=\"dasd ASD\" -- then the quotes will be added as needed.

    HttpClient automatically parses the string you pass in into it's pieces.  When an auth header is needed, it's automatically reconstructed from the parts.

    Network Developer Experience Team (Microsoft)

    • Marked as answer by BradStevenson Tuesday, April 15, 2014 6:17 PM
    Monday, April 14, 2014 6:49 PM