I am trying to make a simpole post request to a registered route using the following method:
// inside a function that registers the rest route
$namespace = 'marketplace/v1';
$route = 'one_image';
register_rest_route($namespace, $route, array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => [$this, 'one_image'],
));
//inside a function
...
$args = array(
'method' => 'POST',
'headers' => array(
'Content-type: application/x-www-form-urlencoded'
),
'sslverify' => false,
'body' => array(
'this' => 'should show in response'
)
);
$response = wp_remote_request($url, $args);
...
public function one_image(\WP_REST_Request $request) {
$params = $request;
$response = new WP_REST_Response($params);
return rest_ensure_response($response); <--- this just returns an empty object
}
Why are my body arguments not being returned in the response?