我试图登录到户外通过API。我不知道为什么它返回错误400错误的请求。 JSON的应该是正确的,在我的ajax调用我也将内容类型设置为应用/ JSON的。
这是我的AJAX调用。
VAR jsonData = JSON.stringify({用户名:usernameV,密码:passwordV}); VAR请求= $阿贾克斯({ 设置:{的contentType:应用/ JSON的}, 键入:POST, 网址:HTTP:// ---知识产权--- /户外/服务/ API /登录, 数据:jsonData });
JSON字符串在控制台中。
{用户名:管理,密码:ADMIN1}
错误
400错误的请求 请求客户端发送的是语法不正确
信息在responseJSON对象
无法解析JSON POST主体:一个JSONObject的文字必须以'{'人品0解决方案
我怀疑这是跟你设置的contentType为发生的唯一途径此路似乎要么是空的JSON或不正确的contentType。尝试:
VAR请求= $阿贾克斯({ 的contentType:应用/ JSON 键入:POST, 网址:HTTP:// ---知识产权--- /户外/服务/ API /登录, 数据:jsonData });I am trying to login to alfresco through api. I do not know why it is returning error 400 Bad Request. The json should be correct and in my ajax call I have also set the content type to 'application/json'.
This is my ajax call.
var jsonData = JSON.stringify({ username : usernameV, password : passwordV }); var request = $.ajax({ settings : {contentType:'application/json'}, type: "POST", url: "---ip---/alfresco/service/api/login", data: jsonData });The json string in the console.
{"username":"admin","password":"admin1"}Error
400 Bad Request Request sent by the client was syntactically incorrectMessage in responseJSON object
Unable to parse JSON POST body: A JSONObject text must begin with '{' at character 0"解决方案
I suspect this is to do with the way you are setting the contentType as the only ways for this to occur appear to either be empty JSON or an incorrect contentType. Try:
var request = $.ajax({ contentType:"application/json", type: "POST", url: "---ip---/alfresco/service/api/login", data: jsonData });
更多推荐
露天登录API提供错误的请求400
发布评论