【发布时间】:2014-12-02 15:32:13
【问题描述】:
我正在尝试在我的 webApi 端点上接受 application/x-www-form-urlencoded 数据。当我向 PostMan 发送明确设置了此 Content-Type 标头的请求时,出现错误:
请求包含实体主体,但没有 Content-Type 标头
我的控制器:
[HttpPost]
[Route("api/sms")]
[AllowAnonymous]
public HttpResponseMessage Subscribe([FromBody]string Body) { // ideally would have access to both properties, but starting with one for now
try {
var messages = _messageService.SendMessage("flatout2050@gmail.com", Body);
return Request.CreateResponse(HttpStatusCode.OK, messages);
} catch (Exception e) {
return Request.CreateResponse(HttpStatusCode.InternalServerError, e);
}
}
邮差帽:
我做错了什么?
【问题讨论】:
标签: asp.net-mvc asp.net-web-api asp.net-web-api2