I am trying to delete a developer, who is logged in into his account. I am doing this through Wordpress website. The registerred wordpress user corresponds to an Apigee developer. In this case I am trying only to remove a developer. If I try with just adding an e-mail at the end of the url it works but when I try to get the email of the currently logged user it gives me the following message.
[body] =>
[response] => Array
(
[code] => 405
[message] => Method Not Allowed
)
[cookies] => Array
(
)
[filename] =>
[http_response] => WP_HTTP_Requests_Response Object
(
[response:protected] => Requests_Response Object
(
[body] =>
[raw] => HTTP/1.1 405 Method Not Allowed
//Delete from apigee
$urlbegin='https://api.enterprise.apigee.com/v1/organizations/xxx-trial/developers/';
$varemail= $current_user->user_email ;
$url= $urlbegin.$varemail;
$args = array(
'method' => 'DELETE','headers'=> array( 'Authorization' => 'Basic xxxxxxxx'));
$response = wp_remote_request( esc_url_raw($url), $args );
if ( is_wp_error( $response ) ) {
$error_message = $response->get_error_message();
echo "Something went wrong: $error_message";
} else {
echo 'Response:<pre>';
print_r( $response );
echo '</pre>';
}