我有一个应用程序,只需单击一个按钮,它就向烧瓶后端发出烧瓶请求(烧瓶不安宁)。如前所述,即使我的标头中包含相同的语句,消息“请求必须具有'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');
}
});
});
});
答案 0 :(得分:0)
headers: {
Accepts: 'application/vnd.api+json',
ContentType: 'application/vnd.api+json',
},
我注意到ContentType末尾有一个逗号。您厌倦了删除它吗?