0

I have this HttpPost Action in one of my application controllers that takes the following parameters:

[HttpPost]
IHttpActionResult Send(List<int> channelsIds, List<uint> destinationsIds, string content, 
                       string title, MessagePriority priority)
{
   ..
}

I know that usually complex objects should be sent through body and simple ones through the uri, but I have read that only one parameter can be taken from the body. If so what is the best way to handle this one?

Moreover, should I perefer to use one of these ways to pass parameters?? Is one of them better?

Edit: Can I join all the parameters into a single SendRequest object? How will that work?

  • Possible duplicate of [How are parameters sent in an HTTP POST request?](http://stackoverflow.com/questions/14551194/how-are-parameters-sent-in-an-http-post-request) – blins Jan 31 '16 at 18:23
  • Looked at that, maybe you can make it clrearer for me. When I use the attribute [HttpPost] - automatically all parameters are binded and received from the request body? –  Jan 31 '16 at 18:41

1 Answers1

0

Check out Asp.Net Web Api model binding it will have more information than you want to know.

In your case, you should wrap up all your parameters into a single model:

public class SendRequest
{
    public List<int> channelsIds {get;set;}
    public List<uint> destinationsIds {get;set;}
    public string content {get;set;} 
    public string title {get;set;}
    public MessagePriority priority {get;set;}
}
Prescott
  • 6,982
  • 4
  • 47
  • 67