N
401 for post requests
Nitesh Kumar over 1 year ago 3191 views 2 replies
TC2:create new user | FAIL |
HTTPError: 401 Client Error: Unauthorized for url: https://gorest.co.in/public/v2/users
TC | FAIL |
getting this error when trying from pycharm through a python code
2 replies
Z
zeevy over 1 year ago
import requests
url = "https://gorest.co.in/public/v2/users"
headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
data = {
"name": "Tenali Ramakrishna",
"gender": "male",
"email": "tenali.ramakrishna@15ce01.com",
"status": "active"
}
response = requests.post(url, headers=headers, json=data)
print(response.status_code)
print(response.json())
Z
zeevy over 1 year ago
import requests
url = https://gorest.co.in/public/v2/users
headers = {
Accept
: application/json
,
Content-Type
: application/json
,
Authorization
: Bearer YOUR_ACCESS_TOKEN
}
data = {
name
: Tenali Ramakrishna
,
gender
: male
,
email
: tenali.ramakrishna@15ce01.com
,
status
: active
}
response = requests.post(url, headers=headers, json=data)
print(response.status_code)
print(response.json())