I am very new to C #, not to mention developing Windows Phone :)
I try to send a request, get a JSON response, but if there is an error (for example, 401), be able to tell the user such. Here is my code:
async Task<string> AccessTheWebAsync()
{
var credentials = new NetworkCredential(globalvars.username, globalvars.password);
var handler = new HttpClientHandler { Credentials = credentials };
HttpClient client = new HttpClient(handler);
Task<string> getStringTask = client.GetStringAsync("https://www.bla.com/content");
String urlContents = await getStringTask;
return urlContents;
}
I know that this should be something that I am doing wrong in the way I submit the request and save the answer ... but I'm just not sure what.
If there is an error, I get the general: net_http_message_not_success_statuscode
Thank!
source
share