سؤال

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