Issue
I have an old curl
(not mine) and I can't figure out how to convert it to use python requests.
Can someone help me?
Here the curl
:
$ch = curl_init($url); //Initiate cURL.
$jsonData = array( //The JSON data.
'email' => $email,
'password' => $password
);
$jsonDataEncoded = json_encode($jsonData); //Encode the array into JSON.
curl_setopt($ch, CURLOPT_POST, 1); //Tell cURL that we want to send a POST request.
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded); //Attach our encoded JSON string to the POST fields.
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'/*, 'Connection: keep-alive'*/)); //Set the content type to application/json
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = json_decode(curl_exec($ch),true); //Execute the request
Solution
Solved
mydata = {'email': form.vars.email, 'password':form.vars.password}
resp= requests.post('url', json = mydata)
I don't know why but I had already tried it and it didn't work
Answered By - Tenebor Answer Checked By - Terry (WPSolving Volunteer)