1. 程式人生 > 實用技巧 >python出現JSON解析出錯的問題:‘message‘: “JSON parse error: Unrecognized token ‘adminUserId‘: was expecting (J

python出現JSON解析出錯的問題:‘message‘: “JSON parse error: Unrecognized token ‘adminUserId‘: was expecting (J

報錯資訊:{‘timestamp’: ‘2020-10-22 22:38:12’, ‘status’: 400, ‘error’: ‘Bad Request’, ‘message’: “JSON parse error: Unrecognized token ‘adminUserId’: was expecting (JSON String, Number, Array, Object or token ‘null’, ‘true’ or ‘false’); nested exception is com.fasterxml.jackson.core.JsonParseException: Unrecognized token ‘adminUserId’: was expecting (JSON String, Number, Array, Object or token ‘null’, ‘true’ or ‘false’)\n at [Source: (PushbackInputStream); line: 1, column: 13]”, ‘path’: ‘/admin/login’}

在這裡插入圖片描述
原因:傳送請求的時候,關注request headers 的content-type, content-type決定輸入引數格式

在這裡插入圖片描述
在這裡插入圖片描述

改為json=params後,這一步執行成功。