Periodic error when creating Custom Collection "expected Array to be a Hash"

4 0 0



Periodically I am getting the following error when a creating custom collection via the REST Admin API:

errors: { publications: 'expected Array to be a Hash' }

We started seeing the error when passing a list of Metafields in the POST request to create the custom collection. Previously we added the metafields as a secondary call after the custom collection was created.


I wrote a script which just repeatedly creates custom collections, and am able to periodically reproduce the problem, though it is not frequent. The script uses the same input parameters except for the collection title.


We use the JS library axios to make the API calls, here is the request:

    url: '/admin/api/2020-04/custom_collections.json',
    method: 'post',
    data: '{"custom_collection":{"metafields":[{"namespace":"accentuate","key":"handle","value":"haikyuuchan","value_type":"string"},{"namespace":"accentuate","key":"handle_link","value":"","value_type":"string"},{"namespace":"accentuate","key":"youtube_link","value":"","value_type":"string"},{"namespace":"accentuate","key":"creator_quote","value":"ðŸ“Karasuno High</br></br><i>\\"My cool test shop\\"</i></br></br>#Karasuno","value_type":"string"}],"title":"e2e-shop-162f0401-5867-4117-b931-40f8b68e522b","published":false}}',
    headers: {
      Accept: 'application/json, text/plain, */*',
      'Content-Type': 'application/json;charset=utf-8',
      'User-Agent': 'axios/0.19.2',
      'Content-Length': 606
    auth: {
      username: XXXX
      password: XXXX
    baseURL: '',


Response body:


errors: { publications: 'expected Array to be a Hash' }


Response headers if this helps at all:


headers: {
    date: 'Sun, 05 Apr 2020 07:05:04 GMT',
    'content-type': 'application/json; charset=utf-8',
    'transfer-encoding': 'chunked',
    connection: 'close',
    'set-cookie': [
      '__cfduid=d56e943a2ce4314f09352e11db4a969781586070304; expires=Tue, 05-May-20 07:05:04 GMT; path=/;; HttpOnly; SameSite=Lax'
    'x-sorting-hat-podid': '44',
    'x-sorting-hat-shopid': '26524647469',
    'referrer-policy': 'origin-when-cross-origin',
    'x-frame-options': 'DENY',
    'x-shopid': '26524647469',
    'x-shardid': '44',
    'x-stats-userid': '',
    'x-stats-apiclientid': '3394067',
    'x-stats-apipermissionid': '212954447917',
    'x-shopify-api-terms': 'By accessing or using the Shopify API you agree to the Shopify API License and Terms of Use at',
    http_x_shopify_shop_api_call_limit: '11/40',
    'x-shopify-shop-api-call-limit': '11/40',
    'x-shopify-api-version': '2020-04',
    'strict-transport-security': 'max-age=7889238',
    'x-shopify-stage': 'production',
    'content-security-policy': "default-src 'self' data: blob: 'unsafe-inline' 'unsafe-eval' https://* shopify-pos://*; block-all-mixed-content; child-src 'self' https://* shopify-pos://*; connect-src 'self' wss://* https://*; frame-ancestors 'none'; img-src 'self' data: blob: https:; script-src 'self' 'unsafe-inline' 'unsafe-eval'; upgrade-insecure-requests; report-uri /csp-report?source%5Baction%5D=create&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Fcustom_collections&source%5Bsection%5D=admin_api&source%5Buuid%5D=3e22a5a5-0b90-40d2-84a1-cd8aed920bc1",
    'x-content-type-options': 'nosniff',
    'x-download-options': 'noopen',
    'x-permitted-cross-domain-policies': 'none',
    'x-xss-protection': '1; mode=block; report=/xss-report?source%5Baction%5D=create&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Fcustom_collections&source%5Bsection%5D=admin_api&source%5Buuid%5D=3e22a5a5-0b90-40d2-84a1-cd8aed920bc1',
    'x-dc': 'gcp-us-central1,gcp-us-east1,gcp-us-east1',
    'x-request-id': '3e22a5a5-0b90-40d2-84a1-cd8aed920bc1',
    'cf-cache-status': 'DYNAMIC',
    'expect-ct': 'max-age=604800, report-uri=""',
    server: 'cloudflare',
    'cf-ray': '57f16b299b82efbc-NRT',
    'alt-svc': 'h3-27=":443"; ma=86400, h3-25=":443"; ma=86400, h3-24=":443"; ma=86400, h3-23=":443"; ma=86400'


Any idea what could be going on?

4 0 0

I should also mention that I see these errors when creating collections serially or in parallel.


The script I wrote which just creates custom collections continues until it errors. When creating collections serially, it first errored on the 44th collection creation. On the next run it errored on the 99th collection, and then on the 103rd collection creation.

Shopify Partner
69 0 16

I just encountered this error yesterday from the REST API when updating a Smart collection. The payload I'm sending exactly matches the sample in the docs:


PUT /admin/api/2020-04/smart_collections/#{smart_collection_id}.json
  "smart_collection": {
    "id": 482865238,
    "published": true

...yet I'm getting the  same "publications expected Array to be a Hash" error.  This endpoint doesn't even have a publications param does it?

11 0 3

There's a similar thread over here:

In my case, I see the error when creating a product. No collections and being pushed with the product create request. Also, this seems to happen randomly. I can make a call which generates the error, then immediately make the exact same call and it works without error.

28 0 3

I am also getting this error intermittently when creating a product variant through /admin/api/2020-04/products.json. I'll send the exact same payload immediately afterward and it works fine. I am also passing published: false which sounds like it might be the culprit. 

I'm going to try updating to 2020-07 API version to see if that helps.