[英]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.