Immutable solution version
MailChimp API wrapper: DELETE always reports failure (204 empty body treated as error)
Complete solution
Shows how to fix mailChimp API wrapper: DELETE always reports failure (204 empty body treated as error). Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
When it applies
Not specified by the original author.
Instructions
TL;DR
Upgrade drewm/mailchimp-api past the July 2016 fix, and check success() by status code rather than body presence for DELETE calls.
Steps
- 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.
- 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.
When to use
Use this skill when you run into "MailChimp API wrapper: DELETE always reports failure (204 empty body treated as error)".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
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 2 · Exact version
Maintainer review
Checking maintainer review for this exact version…
A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.
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>