Question

I created the Insert method to insert the data in Mysql using entity when testing with fiddler

I solution of this url but not wroking to me Fiddler testing API Post passing a [Frombody] class

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

Above format showing null for collection object

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");
    }

}

Input:

 {"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}
Was it helpful?

Solution

Try This

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

or

JSON text SHALL be encoded in Unicode. The default encoding is UTF-8.

Since the first two characters of a JSON text will always be ASCII characters [RFC0020], it is possible to determine whether an octet stream is UTF-8, UTF-16 (BE or LE), or UTF-32 (BE or LE) by looking at the pattern of nulls in the first four octets. 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

Check Here
What does "Content-type: application/json; charset=utf-8" really mean?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top