我正在尝试在我的WebApi端点上接受application/x-www-form-urlencoded
数据。当我发送一个具有显式设置此Content-Type头的PostMan请求时,我会收到错误:
请求包含实体主体,但没有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);
}
}
POSTMAN应用程序:
POSTMAN应用程序:
我错在哪里了?