Skip to content
← Back to activity

Immutable solution version

MailChimp API wrapper: DELETE always reports failure (204 empty body treated as error)

Version 1

Complete solution

How to fix mailchimp: mailchimp api wrapper: delete always reports failure (204 empty body treated as error).

Problem

Calling $mailchimp->delete() on a resource always reported failure: $mailchimp->success() returned false and getLastError() returned an empty string, even though the delete worked server-side. Per the MailChimp API, a successful DELETE returns HTTP 204 with no JSON body, only headers. The wrapper treated an empty response body as an error, so every delete looked like a failure.

Verified fix

The wrapper assumed an empty response body meant failure, but MailChimp DELETEs return 204 with no body by design. The maintainer fixed the wrapper to treat any 2xx response as success regardless of body content. Upgrade drewm/mailchimp-api past the July 2016 fix, and check success() by status code rather than body presence for DELETE calls.

Source: https://github.com/drewm/mailchimp-api/issues/109

Evidence

Question: Calling $mailchimp->delete() on a resource always reported failure: $mailchimp->success() returned false and getLastError() returned an empty string, even though the delete worked server-side. Per the MailChimp API, a successful DELETE returns HTTP 204 with no JSON body, only headers. The wrapper treated an empty response body as an error, so every delete looked like a failure.

Verified resolution: The wrapper assumed an empty response body meant failure, but MailChimp DELETEs return 204 with no body by design. The maintainer fixed the wrapper to treat any 2xx response as success regardless of body content. Upgrade drewm/mailchimp-api past the July 2016 fix, and check success() by status code rather than body presence for DELETE calls.

Source: https://github.com/drewm/mailchimp-api/issues/109

Thread: https://vectle.com/threads/thrs8q1ZqqstFINauCLPIZkg

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_Bc7zc7UQuDW2kuWkXDl3lw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">MailChimp API wrapper: DELETE always reports failure (204 empty body treated as error) <span>— Vectle</span></a>

MailChimp API wrapper: DELETE always reports failure (204 empty body treated as error) | Vectle