Hi guys i am trying to send getasync request with silverlight 5. the post async is working without any problem but the getasync throw that exception when adding authorization header. when not adding authorization header this is without exception just 401. what should i do to fix it?
the code:
client.DefaultRequestHeaders.Add("Authorization", "Bearer secrettoken");
var getasynctask = await client.GetAsync("http://api.enteroption.com/api/UserDetails/GetUserIdByToken/");
the exception:
System.ArgumentException occurred
Message=""
StackTrace:
at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
at Microsoft.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at ConsoleApplication3.Class1.<Func>d__1.MoveNext()
InnerException: System.ArgumentException
Message=Value does not fall within the expected range.
StackTrace:
at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClassa.<EndGetResponse>b__9(Object sendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__0(Object sendState)
InnerException: