'Problem when request HTTP post request using py
I am having a problem when requesting a POST request from this API: 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)
Error message: {"message":"Failed to unmarshal request body: invalid character 'o' in literal true (expecting 'r')","isSuccess":false}
Solution 1:[1]
Instead of data = myobj in response variable use json = myobj
Remove the parentheses in myobj variable
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Septimus |
