I'm trying to passing Json Data with Ajax to SpringBoot, but it's throwing error, What is the mistake in my program Pls tell me and suggest me. what is the mistake.
var emailId = {"emailId" : userEmail};
$.ajax({
url : "/api/v1/leadsquard/user/emailId",
type : "GET",
data : JSON.stringify(emailId),
dataType : "text",
contentType: "application/json",
success: function (response) {
alert("Success "+ JSON.stringify(response));
},
error: function(response) {
alert("Success "+ JSON.stringify(response));
}
});
Controller Class
@RestController
@RequestMapping(value = "/api/v1")
public class LeadSquardController {
@Autowired
LeadSquardService leadSquardService;
@GetMapping("leadsquard/user/emailId")
@ResponseBody
public String getByEmailaddress(@RequestBody Object emailId) {
System.out.println("Email : " + emailId.getClass().getName()); //Testing line
System.out.println("Email : " + emailId); //Testing line
return "";
}
}