三默网为您带来有关“java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line的解决办法(python请求)”的文章内容,供您阅读参考。

java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line的解决办法(python请求)

2023-01-21 19:48:30

#java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line…

使用python请求一直服务端返回500 ,使用postman确认无误后,看后台日志,总是输出java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line…

于是尝试修改的json
原json ——使用抓包工具抓取的

adddata = {
            "input": [
            {
            	"user_name": userName,
            	"password": password,
            	"full_name": fullName,
            	"description": "",
            	"access_profile": "0",
            	"email": "",
            	"idle_session_timeout": 120,
            	"expired": "0",
           	 	"assigned_role": [
                	"0"
            	],
            	"pwd_change_next": "false",
            	"alarm_flash": "false",
            	"alarm_sound": "false"
            	}
            ]
        }

修改后的json,去掉了input ,最后请求成功

adddata = {
            "user_name": userName,
            "password": password,
            "full_name": fullName,
            "description": "",
            "access_profile": "0",
            "email": "",
            "idle_session_timeout": 120,
            "expired": "0",
            "assigned_role": [
                "0"
            ],
            "pwd_change_next": "false",
            "alarm_flash": "false",
            "alarm_sound": "false"
 
        }