Have an existing API that suddenly stopped working. GuzzleHttp
is used in this project.
Cannot delete users over an API with Mailchimp. Response;
405 Method Not Allowed response: {"type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/","title":"Method Not Allowed", "st (truncated...) in vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Here is my code;
public function __construct()
{
$this->client = new Client([
'auth' => ['bread', getenv('MAILCHIMP_API_KEY'), 'basic'],
]);
}
public function delete_member_from_list(string $member_email, string $list_id): ResponseInterface
{
$subscriber_hash = $this->get_subscriber_hash($member_email);
// Just making sure vars are defined and they are
error_log('List id: ' . $list_id);
error_log('Hash: ' . $subscriber_hash);
return $this->client->delete("{$this->endpoint}/lists/{$list_id}/members/{$subscriber_hash}");
}
Mailchimp documentation states: This error means that the requested resource does not support the HTTP method you used.
And this is from the API documentation for deleting a member from a list;
And finally from Guzzle;
So it seems as the http method is right but Mailchimp still returning 405.
Thanks in advance.
Info;
- PHP 7.2.19-0ubuntu0.18.04.2 (cli) (built: Aug 12 2019 19:34:28) ( NTS )
- SSL