I have a web api with the following POST method
public HttpResponseMessage Post([FromBody]string package)
I have a console application that uses HttpCLient without problems. When I try to make a call using jQuery , I get null in the package variable.
This is the code that I have right now:
$.ajax({ url: 'http://localhost:8081/api/Package/', type: 'POST', data: JSON.stringify(message), contentType: "application/json;charset=utf-8", success: function (data) { alert(data.length); }, error: function (xhr, ajaxOptions, thrownError) { alert('Status: '+xhr.status+', Error Thrown: '+thrownError); } });
The variable "message" is a complex model containing two properties.
What can i do wrong?
I would be grateful for your help ...
source share