露天登录API提供错误的请求400

编程入门 行业动态 更新时间:2024-10-28 10:28:54
本文介绍了露天登录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: "---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: "---ip---/alfresco/service/api/login", data: jsonData });

更多推荐

露天登录API提供错误的请求400

本文发布于:2023-10-12 02:35:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483517.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:露天   错误   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!