Search code examples
c#apifiddler

Web API Test using Fiddler return null


When i test following API using fiddler always set the parameter myRequest with null value. how i can fix this?

API

public HttpResponseMessage Post([FromBody]MyRequest myRequest)
        {

        }

Model

public class MyRequest
{
    public int[] MyId { get; set; }
}

Fiddler Test

http://localhost:4037/api/PostTest

Request Body

{
    "MyRequest": {
        "MyId": [
            1,
            2
        ]
    }
}

Solution

  • You don't need "MyRequest" in the JSON...

    {
        "MyId": [
            1,
            2
        ]
    }