Click here to Skip to main content
15,847,427 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to send a parameter for a post method in restful api. Consuming service as below

$.ajax({
type: "POST",
url: "MyUrl/UpdateCustomer",
data: '{"customerJsonData": "' + "Test" + '"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
crossDomain: true,
success: function (data, status, jqXHR) {
debugger;
alert("success" + " " + data); // write success in " "
},
error: function (jqXHR, status) {
debugger;
// error handler
console.log(jqXHR);
alert('fail' + status.code);
}
});

Its always sending "null" for parameter customerJsonData(string type). Is there any change need to be done to make it work?

Thanks in advance
Posted

1 solution

I think you need to stringify.

Refer - Sending JSON to WCF Rest Service - object is always null[^]
 
Share this answer
 
Comments
Mada Naga Sankar 6-Sep-15 13:55pm    
I tried this, still value is null.
Did you debug? Is it going inside that method?

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