I have a problem like the topic says. I'm new with that stuff and I don't even know where to look for that issue. That's my post method:
public class Point
{
public string x { get; set; }
public string y { get; set; }
}
[HttpPost]
public IHttpActionResult Post([FromBody] Point point)
{
// do stuff
return StatusCode(HttpStatusCode.OK);
}
and that's my ajax request:
var x = $('#input1').val();
var y = $('#input2').val();
$("#btnUpload").click(function () {
$.ajax({
type: "POST",
url: "api/images",
data: { x: x, y: y },
success: function (result) { alert(result) },
error: function (err) { alert(err.statusText) }
});
});
Did I forget about something?
EDIT: My controller:
[RoutePrefix("api/images")]
public class ImagesController : ApiController
{
private Bitmap CreateBoard()
{
// some stuff I need
}
[HttpPost]
public IHttpActionResult Post([FromBody] Point point)
{
// do stuff
return StatusCode(HttpStatusCode.OK);
}
[Route("")]
[HttpGet]
public List<int> Get()
{
// do other stuff
}
[Route("{id}")]
[HttpGet]
public HttpResponseMessage Get(int id)
{
// do other other stuff
}
}
GET is working fine.