在使用fiddler测试时,我创建了Insert方法来使用实体将数据插入到Mysql中
我解决了这个网址,但对我不起作用 Fiddler testing API Post passing a [Frombody] class
User-Agent: Fiddler
Host: localhost:4086
Content-Length: 193
Content-type: application/json; charset=utf-8
以上格式显示集合对象为空
public class InsertController : BaseApiController
{
static readonly IInsertMaster obj = new InsertMaster();
[HttpPost]
public HttpResponseMessage PostUser(collection_master collection)
{
if (collection == null)
return Request.CreateResponse(HttpStatusCode.BadRequest, "not created");
if (obj.PostUser(collection))
{
return Request.CreateResponse(HttpStatusCode.Created, TheModelFactory.create(collection));
}
else
return Request.CreateResponse(HttpStatusCode.BadRequest, "Could not save to the database");
}
}
输入:
{"CustomerID":"10","AmountRecevied":1000","Date_Time":"2014-03-03 10:00:00","Area":"banglore","AgentID":"1","Money_Receipt_No":"123456","Payment_Mode":"cheque","Money_Receipt_Photo":null}
最佳答案
试试这个
Content-type: application/json; charset=utf-8
或
JSON 文本应以 Unicode 编码。默认编码为 UTF-8。
由于 JSON 文本的前两个字符始终是 ASCII 字符 [RFC0020],因此可以确定八位字节流是 UTF-8、UTF-16(BE 或 LE)还是 UTF-32(BE或 LE)通过查看前四个八位字节中的空值模式。 00 00 00 xx UTF-32BE 00xx 00xx UTF-16BE xx 00 00 00 UTF-32LE xx 00 xx 00 UTF-16LE xx xx xx xx UTF-8
在这里检查
What does "Content-type: application/json; charset=utf-8" really mean?
关于mysql - [FORMBODY参数为空?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23358598/