[英]AJAX POST throws a 415 Unsupported Media Type Error with message 'Request must have “Content-Type:application/vnd.api+json”'
我有一个应用程序,单击按钮后,它会向烧瓶后端(烧瓶不安)发出ajax发布请求。 如前所述,即使我的标头中包含相同的语句,消息“请求必须具有'Content-Type:application / vnd.api + json'”也会出现错误。 指针,发布请求已成功发布到邮递员上。
$(function() {
$('#add_details').on('click', function() {
$.ajax({
type: 'POST',
url: 'http://127.0.0.1:5000/api/v1/user',
data: {
"data": {
"type": "user",
"attributes": {
"first_name": "first",
"last_name": "second",
"email_address": "user43@gmal.acbde",
"phone_number": "4202024234",
"gender": "FEMALE"
}
}
},
headers: {
Accepts: 'application/vnd.api+json',
ContentType: 'application/vnd.api+json',
},
dataType: "json",
success: function(newUser) {
console.log('success', newUser)
},
error: function() {
alert('error encounted while adding user');
}
});
});
});
headers: {
Accepts: 'application/vnd.api+json',
ContentType: 'application/vnd.api+json',
},
我注意到ContentType末尾有一个逗号。 你厌倦了删除吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.