Search code examples
androidxamarinandroidhttpclient

Xamarin HttpClient request


Hi Xamarin Jedi masters !!!

I need a litle help First, I set the value of the Token

user.Token = "email@hotmail.com:1395694497451:799fcaa9f86ff10604ca0c6135313697";

Then I added the property to the Header :)

request.Headers.Add ("Auth-Token", user.Token); <------ HERE !!!

Then I call: var response = client.SendAsync (request).Result;

I´m receiving the message :

Unauthorized: Authentication token was either missing or invalid.

description This request requires HTTP authentication

BUT .. LISTEN !!!

If I put directly.... that way: request.Headers.Add ("Auth-Token", "email@hotmail.com:1395694497451:799fcaa9f86ff10604ca0c6135313697");

works !!!!!!!

Please ..... Somebody tell me how I can fix that and use the value that came from property user.Token......

sorry about my english


Solution

  • you will not believe!

    It was simply remove quotes

    @ user.Token.Trim ('"') <---- MAGIC!