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
        ]
    }
}
有帮助吗?

解决方案

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

{
    "MyId": [
        1,
        2
    ]
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top