我試圖接受我的webApi端點上的application/x-www-form-urlencoded
數據。當我送與具有這種Content-Type頭明確設置郵遞員的請求,我得到一個錯誤:WebApi - 請求包含實體正文,但沒有Content-Type標頭
The request contains an entity body but no Content-Type header
我的控制器:
[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("[email protected]", Body);
return Request.CreateResponse(HttpStatusCode.OK, messages);
} catch (Exception e) {
return Request.CreateResponse(HttpStatusCode.InternalServerError, e);
}
}
郵差帽:
我做錯了什麼?
你就像WebAPI Badri的蝙蝠俠。感謝您再次拯救我的一天。 – SB2055 2014-10-08 13:54:57