[英]“invalid character 'u' looking for beginning of value”Parsing Error from an Service developed in golang
I am trying to have the response from API which is developed in Golang. 我正在尝试从Golang中开发的API获得响应。 Using PostMan I get the proper response, but when I use requests library, I get the following message:
使用PostMan可以得到正确的响应,但是当我使用请求库时,会收到以下消息:
{
u'status':400,
u'title':u'Unable to parse data',
u'code':u'400001',
u'id':u'edf83LlwYx',
u'detail':u"invalid character 'u' looking for beginning of value"
}
My Python script is: 我的Python脚本是:
import requests
import json
import data
url = data.user_login
headers = {
'Content-Type': 'application/json',
'content-encoding': 'deflate'
}
form = {
"username": "askjhashdasjd",
"password": "asdfASDF1234#="
}
response = requests.post(url,headers=headers, data=form)
json_data = json.loads(response.text)
print json_data
I am getting the proper response from the other services using this script. 我正在使用此脚本从其他服务获得正确的响应。
data_to_send = json.dumps(form).encode("utf-8")
response = requests.post(url, data=data_to_send)
This Makes the thing done :) 这使事情完成了:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.