'How to convert Curl SSL and auth request to Python code
I would like to convert my request written in Curl to Python. I'm ignoring ssl becouse this certificate is signed by me. I am not sure if I have correctly replaced the value of "description" from null to None. How to improve my query written in Python?
Curl
curl -k -i -u 'admin:admin' --header 'Content-Type: application/json' -d '{"name": "Testowa Rola 221", "description": null, "privilegeIds": [1, 2, 3], "userIds": []}' -X POST https://localhost:44411/api/Role
Python
import requests
url = 'https://localhost:44411/api/Role'
data = {
"name": "Test name 12",
"description": None,
"privilegeIds": [1, 2, 3],
"userIds": []
}
headers = {
'Content-Type': 'application/json'
}
auth = (
'admin',
'admin'
)
verify = '/home/dominik/jpk/xefix/ssl/https.crt'
create_administrator = requests.post(url=url, verify=verify, headers=headers, data=data, auth=False)
print(create_administrator.text)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
