露天登录API提供错误的请求400 [英] Alfresco login api giving Bad Request 400

查看:253
本文介绍了露天登录API提供错误的请求400的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图登录到户外通过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: "http://---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 incorrect

Message 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: "http://---ip---/alfresco/service/api/login",
    data: jsonData
});

这篇关于露天登录API提供错误的请求400的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆