我在从此 API 请求 POST 请求时遇到问题:https://docs.pixe.la/entry/post-user
import requests as re
url = 'https://pixe.la/v1/users'
myobj =({"token":"tonybui",
"username":"Tonybui2003",
"agreeTermsOfService":"yes",
"notMinor":"yes"})
# {"message":"Success. Let's visit https://pixe.la/@a-know , it is your profile page!","isSuccess":true}
response = re.post(url, data = myobj)
# data = response.json()
print(response.text)
错误信息:
{"message":"Failed to unmarshal request body: invalid character 'o' in literal true (expecting 'r')","isSuccess":false}
代替
response变量中的
data = myobj
使用 json = myobj
删除myobj变量中的括号
错误可能是因为您的 request=>response = request.post(url=url, json= myobj)