2014-04-29 97 views
0

我拉琴測試此網址的[FORMBODY參數爲空?

我的解決方案的時候,但不wroking我 Fiddler testing API Post passing a [Frombody] class

User-Agent: Fiddler 
Host: localhost:4086 
Content-Length: 193 
Content-type: application/json; charset=utf-8 

上面的格式顯示空的集合對象

創建的插入方法,使用實體在MySQL中插入數據
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} 

回答

1

嘗試這個

Content-type: application/json; charset=utf-8 

JSON內容應以Unicode編碼。默認編碼是UTF-8。由於JSON文本的前兩個字符總是ASCII字符[RFC0020],因此可以確定八位位組流是UTF-8,UTF-16(BE還是LE)還是UTF-32(可能是UTF-8) 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?