6
在POST中将JSON发送到Web API服务时出错
我正在使用Web API创建Web服务。我实施了一个简单的课程 public class ActivityResult { public String code; public int indexValue; public int primaryCodeReference; } 然后我在控制器内部实现了 [HttpPost] public HttpResponseMessage Post(ActivityResult ar) { return new HttpResponseMessage(HttpStatusCode.OK); } 但是,当我调用POST中传递的API时,文件为json: {"code":"XXX-542","indexValue":"3","primaryCodeReference":"7"} 我收到以下错误消息: { "Message": "The request entity's media type 'text/plain' is not supported for this resource.", "ExceptionMessage": "No MediaTypeFormatter is available to …