wp_remote_request returning ‘400 Bad request’
-
Hi
I am trying to make a call to admin-ajax.php through the wp hook:
wp_remote_request.
I have read the documentation and I can’t seem to find any problems. I have tried to use thewp_remote_posthook as well but with same outcome.I am trying to make the request fire an action in the admin-ajax file and return the data.
The request is fired after it receives a post request from a remote site I am also managing, where I am sending the nonce etc.The request:
$args = array( 'method' => 'POST', 'timeout' => '50', 'redirection' => '5', 'blocking' => true, 'headers' => array(), 'cookies' => array(), 'body' => array( 'offset' => '0', 'limit' => '100', 'action' => 'wordfence_loadIssues', 'nonce' => $_POST['nonce'] ) ); $response = wp_remote_request(admin_url('admin-ajax.php'), $args); $response_code = wp_remote_retrieve_response_code($response); $response_body = wp_remote_retrieve_body($response); wp_send_json_success(array('code' => $response_code, 'body' => $response_body, 'nonce' => $_POST['nonce'])); exit();Hope you can help me or point me in the right direction.
Thank you 🙂
Viewing 15 replies - 1 through 15 (of 15 total)
Viewing 15 replies - 1 through 15 (of 15 total)
The topic ‘wp_remote_request returning ‘400 Bad request’’ is closed to new replies.