【发布时间】:2014-11-12 00:35:23
【问题描述】:
我们正在构建一个 WinRT 应用程序,该应用程序从基于 Web API 的服务器获取数据,因此它以 json 和/或 XML 格式提供数据。
当应用用户第一次使用他的凭据(用户名,密码)登录时,来自服务器的响应是一个成功位和一个 TOKEN,应该在后续的 URL 请求中使用。
我正在使用 httpclient 发送请求
using (HttpClient httpClient1 = new HttpClient())
{
string url = "http://example.com/abc/api/process1/GetLatestdata/10962f61-4865-4e7a-a121-3fdd968824b5?employeeid=6";
//The string 10962f61-4865-4e7a-a121-3fdd968824b5 is the token sent by the server
var response = await httpClient1.GetAsync(new Uri(url));
string content = await response.Content.ReadAsStringAsync();
}
现在我得到的响应是状态码 401“未经授权”。 我得到的响应是“未经授权的用户”。
我需要在 appManifest 中更改什么吗??
我检查了this,但我们不能在没有凭据的情况下使用 httpclient 吗??
【问题讨论】:
标签: windows-runtime windows-store-apps winrt-xaml asp.net-web-api