Bad request 400 – no email
-
Hi Dominik,
Thanks a lot for your great plugin!
I achieve to get a result with postman, but when I do it from curl with php, I get this error:
{“code”:”no_email”,”message”:”You must provide an email address.”,”data”:{“status”:400}}
Here is my code:
$curl = curl_init(); $header = array(); $header[] = 'Content-length: 0'; $header[] = 'Content-type: application/json'; $header[] = 'Accept: application/json'; $header[] = 'Authorization: Bearer < my token here >'; $postRequest = array( 'email' => $fields['email'], ); curl_setopt_array($curl, array ( CURLOPT_URL => '< my base url here >/wp-json/bdpwr/v1/reset-password', CURLOPT_POST => true, CURLOPT_POSTFIELDS => $postRequest, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_HTTPHEADER => $header, )); $response2 = curl_exec($curl); curl_close($curl); error_log($response2);
Hope you’ll see what I did wrong.
Just so you know Ive done other curl get requests with another API and it’s working and I’ve checked the variable I send for the email ($fields[’email’]) and it’s the right one. Just to see if it came from there, I tested to encode it with urlencode_deep and still not working. But I believe I don’t need to encode it to make it work, because from postman I didn’t have to do it.
Thanks a lot
- The topic ‘Bad request 400 – no email’ is closed to new replies.