Click here to Skip to main content
15,867,954 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How can I send two parameters in asp.net web api HttpPost? Assume that I don't want to change MapRoute.

What I have tried:

// POST: api/Settings/163/20
[HttpPost]
public bool PostSetting([FromRoute] int facilityId,int bandwidthRequest)
{
if (!ModelState.IsValid)
{
return HttpBadRequest(ModelState);
}
Posted
Updated 17-May-16 2:58am
v2
Comments
Member 11902764 17-May-16 5:10am    
Try posting object, which holds these 2 values. API and your project should have same class name.

1 solution

Below could be one of the possible solution
C#
[Route("api/YOURCONTROLLER/{paramOne}/{paramTwo}")]
    public string PostSetting(int paramOne, int paramTwo)
    {
        
    }
The {} names need to match your parameters.</pre>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900