我想在我的ASP.Net Web API Controller中返回一个文件,但我的所有方法都返回HttpResponseMessage
为JSON.
public async Task<HttpResponseMessage> DownloadAsync(string id)
{
var response = new HttpResponseMessage(HttpStatusCode.OK);
response.Content = new StreamContent({{__insert_stream_here__}});
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
return response;
}
Run Code Online (Sandbox Code Playgroud)
当我在浏览器中调用此端点时,Web API会返回设置HttpResponseMessage
为HTTP Content Header 的as JSON application/json
.
PUT
请求/beta/groups/<groupId>/team
失败,并出现以下错误:
{
"error": {
"code": "AuthenticationError",
"message": "Error authenticating with resource.",
"innerError": {
"request-id": "e4385864-85e4-4fa6-8878-458988c584e4",
"date": "2017-11-10T10:29:39"
}
}
}
Run Code Online (Sandbox Code Playgroud)
提供了一个Bearer令牌,它是通过使用委托权限生成的Group.ReadWrite.All
.
端点记录在此处.
看起来,它与团队资源有关.以下请求不起作用:
PUT /beta/group/<groupId>/team
GET /beta/me/joinedTeams
两者都失败了AuthenticationError
.
/beta/group/<groupId>/team
现在工作.