I need to do the following CURL request in python:
curl -X POST https://fake.url
-H 'apiKey: {apiKey}'
-H 'Content-Type: application/json'
-H 'Accept: application/json'
-d '{ "data": { "dirname": "{dirname}", "basename": "{filename}", "contentType": "application/octet-stream" } }'
I implemented this using the "requests" module installed via pip:
try:
import requests
except ImportError:
os.system("pip install requests")
import requests
...
url = 'https://fake.url'
headers = {
'apiKey': f'{apiKey}',
'Content-Type': 'application/json',
'Accept': 'application/json',
}
payload = json.dumps({
'data': {
'dirname': f'{dirname}',
'basename': f'{filename}',
'contentType': 'application/octet-stream'
}
})
response = requests.post(url, headers=headers, data=payload)
The customer requested NOT to use pip to install the "requests" module. Is it possible to do this? Or, is it possible to perform the CURL request without the "requests" module?