I am trying to convert the following PHP curl_setopt() to the equivalent within Python Requests as well as for CLI curl. For Python, if not possible in Requests, I will resort using pycurl.
curl_setopt($process, CURLOPT_RETURNTRANSFER, true);
curl_setopt($process, CURLOPT_SSL_VERIFYPEER, false);
Here is the working PHP curl code:
$params = array(
'username' => $username,
'password' => $password
);
$params_string = json_encode($params);
$process = curl_init($url);
curl_setopt($process, CURLOPT_RETURNTRANSFER, true);
curl_setopt($process, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($process, CURLOPT_POSTFIELDS, $params_string);
$headers = array();
$headers[] = 'Content-Type: application/json';
curl_setopt($process, CURLOPT_HTTPHEADER, $headers);
$data = curl_exec ($process);
curl_close ($process);
I am at a loss what I need to set within Python Requests for those two PHP curl_setopt(s).
And I have tried the following in CLI curl, but I got a Bad Request error:
AUTHENTICATE_DATA="usename=${USERNAME}&password=${PASSWORD}"
AUTHENTICATE_RESPONSE=$(curl \
-X POST \
-H 'Content-Type: application/json' \
--data-urlencode "${AUTHENTICATE_DATA}" \
-v \
${AUTHENTICATE_URL})
echo ${AUTHENTICATE_RESPONSE}
What do I need?
Thank you, appreciate the assistance.