ASP.NET Web API Multiple parameters binding

        public void Post([FromBody]string value)
        {
        }

The above is the default POST request which only accept one value and the value must be passed in from the body of the POST request as suggested from the parameter [FromBody].

In order to accept parameter directly from the uri such as /api/default?id=123&payload=bob and also accept multiple parameters. You would need to change the [FromBody] to [FromUri]. An example which allows multiple parameters from the POST uri is shown below.

        public void Post([FromUri]string id, [FromUri]string payload)
        {
        }

Referenced from Mike Stall

Advertisements
This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

One Response to ASP.NET Web API Multiple parameters binding

  1. Anonymous says:

    its a work around according to me

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s