I have working requests code in python and need it in ajax
var jsonData = {"x":"y"};
$.ajax({
url: url,
type: 'POST',
data: jsonData,
//dataType: "JSON",
error: function(e) {
console.log(e);
}
});
json: jsonData, JSON.stringify, 'Content-Type': 'application/json' and changing names doesn't work, I tried a lot of things, but everytime error 400
this python code works fine
payload = {
'a':'b',
'a': 'b'
}
#but it doesn't work with field 'data' or 'params', must be named 'json'
r = requests.post(url, json=payload) #data=payload won't work, otherwise error 400
print(r.text)
try setting contentType: "application/json" on ajax