I am getting post as null in My API controller Action GetVoteScores. Where i went wrong?. If any one need more code to check i will give it.
This is my API controller Action
[System.Web.Mvc.HttpGet]
[System.Web.Mvc.ActionName("GetVoteScores")]
public string GetVoteScores(int id, int UserId, int IsUpVote,Post post)
{
return "1";
}
This is my WebApI.config file
config.Routes.MapHttpRoute(
name: "MyRoute",
routeTemplate: "api/{controller}/GetVoteScores/{id}/{UserId}/{IsUpVote}",
defaults: new { id = RouteParameter.Optional, UserId = RouteParameter.Optional, IsUpVote = RouteParameter.Optional }
);
And finally my Ajax call look like
var post = new Post();
post.PostId = self.PostId;
post.PostedBy = self.PostedBy;
return $.ajax({
url: postApiUrl + "GetVoteScores/" + self.PostId + "/1/0",
dataType: "json",
contentType: "application/json",
cache: false,
type: 'GET',
data: ko.toJSON(post)
})