我创建了Insert方法,以便在使用fiddler
进行测试时使用实体在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}
答案 0 :(得分:1)
试试这个
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 00 xx 00 xx 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?