我想在一个网站(在那里我已经注册)来发布表单数据,以下是我的代码: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