我想在一個網站(在那裏我已經註冊)來發布表單數據,以下是我的代碼:AJAX調用後導致422錯誤
$.ajax({
url:'https://api.contentstack.io/v2/content_types/the_lazy_goose/entries/',
type: "POST",
contentType: "application/json",
data: JSON.stringify({
title: "John",
url: "2pm",
multi_line: "Random Text using Post call"
}),
headers:{
access_token: 'xxxxxxxxxxx',
api_key: 'xxxxxxxxx'
},
success: function() {
alert("success");
},
error: function() {
alert("ERROR");
},
});
這導致422(無法處理的實體) ,不知道哪裏出錯。 *我已經通過了http://www.restpatterns.org/HTTP_Status_Codes/422_-_Unprocessable_Entity並理解「request_entity」 &「的要求語法」都很好
該網站https://contentstackdocs.built.io/rest/api/content-management-api/似乎支持JSON數據
您確定'https:// exampleurl.com/goose/entries /'是允許POST動詞的有效URL嗎?試試這個:http://jsonplaceholder.typicode.com/ – urbz
對不起,我提到的鏈接只是一個隨機文本。我正在發佈的網站允許POST,GET – iyerrama25
好的,你確定那麼你提到的API允許'json'作爲contentType呢?也許不要指定或只是爲了實驗目的,'application/xml'說的是什麼,statuscode ..? – urbz