1

How to send object array as parameter to MVC Controller?

public class FeedStats
{
    public long FeedId { get; set; }
    public ApiType ApiType { get; set; }
    public long UserId { get; set; }
    public float ReadTime { get; set; }
    public long FeedIndex { get; set; }
    public bool IsWebRead { get; set; }
}

In Controller

[HttpPost]
public HttpResponseMessage UpdateFeedStats(FeedStats[] data)
{
}

When i make HttpPost request with Postman with these parameters, the data is always null. Whats an issue?

Headers:

Content-Type: application/json

{
data: [
   FeedId: 1,
   ApiType: 1,
   UserId: 1,
   ReadTime: 0.65,
   FeedIndex: 1,
   IsWebRead: 1
]
}
3
  • Could you show how you are making the request? Commented Sep 12, 2013 at 6:34
  • i updated my question with request headers. pls check. Commented Sep 12, 2013 at 6:36
  • @haim770, Thanks it works, hi can u pls post that as an answer. I will accept it. Commented Sep 12, 2013 at 6:41

1 Answer 1

1

Since FeedStats[] is an array of Objects. you need to enclose the inner object with curly braces as well:

{
data:[
     {FeedId:1,...},
     {...},
     {...}
     ]
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.