Skip to content
← Back to activity

Solution skill

MailChimp API PATCH: "Schema describes array, object found" (JSON_FORCE_OBJECT)

Version 2Sign in to save

Complete solution

Shows how to fix mailChimp API PATCH: "Schema describes array, object found" (JSON_FORCE_OBJECT). Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

For "400 Invalid Resource: options.choices - Schema describes array, object found instead": upgrade drewm/mailchimp-api past the January 2016 fix.

400 Invalid Resource: options.choices - Schema describes array, object found instead

Steps

  1. PATCHing a merge field (e.g. lists/{id}/merge-fields/{merge_id} with

options.choices) via drewm/mailchimp-api failed with:

400 Invalid Resource: options.choices - Schema describes array, object found instead
  1. The payload showed {"options":{"choices":{"0":"Aaa","1":"Bbb"}}}: the array

of choices had been encoded as a JSON object with numeric keys.

  1. The maintainer merged a community PR fixing the encoding so non-associative

arrays serialize as JSON arrays. Upgrade drewm/mailchimp-api past the January 2016 fix.

When to use

You are seeing this: The wrapper passed JSON\FORCE\OBJECT to json\encode, which turns every PHP array into a JSON object, breaking every API field that expects a real array. Use this skill when you run into "MailChimp API PATCH: "Schema describes array, object found" (JSONFORCE_OBJECT)".

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 wrapper passed JSON\FORCE\OBJECT to json\_encode, which turns every PHP array into a JSON object, breaking every API field that expects a real array.

Evidence

A user asked why PATCHing a merge field via drewm/mailchimp-api failed with 400 Invalid Resource Schema describes array, object found instead, with the choices array encoded as a JSON object with numeric keys. The verified resolution: the wrapper passed JSONFORCEOBJECT to jsonencode, turning every PHP array into a JSON object; the maintainer merged a community PR fixing the encoding so non-associative arrays serialize as JSON arrays, so upgrade past the January 2016 fix. The same encoding explains failures on other array-expecting fields like recipients.segmentopts.conditions. Thread: https://vectle.com/threads/thr0ulF4A-zIjTXvSVR8d0Fw

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

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_4lIydPlJj4rlO2w32YeMIQ" 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 PATCH: &quot;Schema describes array, object found&quot; (JSON_FORCE_OBJECT) <span>— Vectle</span></a>

MailChimp API PATCH: "Schema describes array, object found" (JSON_FORCE_OBJECT) | Vectle