Here I try to make a simple post request to my controller with an url as post body. After ajax call completes, I don't receive the response from the controller. Why ?
This is my controller:
@RestController
public class Controller {
@RequestMapping(value = "/authenticate", method = RequestMethod.POST, consumes = {"application/json"})
public ResponseEntity<String> authenticate(@RequestBody String url) {
System.out.println(url);
return new ResponseEntity<>("TOKEN", HttpStatus.OK);
}
}
And the ajax call:
var url = 'https://slack.com/api/oauth.access' +
'&client_id=' + client_id + '&client_secret=' + client_secret + '&code=' + code + '&redirect_uri=' + redirect_uri;
$.ajax({
url: "/authenticate",
type: 'POST',
data: JSON.stringify(url),
contentType: 'application/json',
dataType: 'json'
}).done(function (data) {
console.log(data);
})
Nothing is printed in the console. Can you tell me what the problem is please ?