I've created a Web API Action as below
[HttpPost]
public void Load(string siteName, string providerName, UserDetails userDetails)
{
// implementation
}
The route I've registered for this is as below (not sure if it's correct?):
config.Routes.MapHttpRoute(
name: "loadUserDetails",
routeTemplate: "sites/{siteName}/User/Load/{providerName}/{userDetailsList}",
defaults: new
{
controller = "User",
action = "Load",
providerName = UrlParameter.Optional
});
The providerName parameter should be optional and I'm using Xml Serialization.
The action should response to the below url sample:
http://www.domain.com/sites/site1/user/load/provider1/[some user details in the post]
or
http://www.domain.com/sites/site1/user/load/[some user details in the post]
How could I make a post call to this action so that I can test my service?
From: HTTP request with post
See the response from here using RestSharp and Web Request:
http://pooyakhamooshi.blogspot.co.uk/2013/04/how-to-post-request-to-web-api-web.html
If your question is how to test your action, you can use Fidler.
See http://www.mehdi-khalili.com/fiddler-in-action/part-2