CollectionCreate with publications fails but succeeds without

davideagle
New Member
1 0 0

 

I'm creating dynamic collections through GraphQL API with out problems, but how ever when want to publish them and specify publications on the Collection I receive an error message "CollectionCreate access denied"

I'm using the deprecated  CollectionPublicationInput.channelId field because without a shopifyPlus store you apparently can not access Publications

"Access denied for publications field. Required access: `read_publications` access scope. This scope is currently available only to private apps installed on Shopify Plus stores. Contact Shopify Partner Support to enable the scope for your app."

https://shopify.dev/api/admin-graphql/2021-10/mutations/collectionCreate 

Mutation

 

 

mutation collectionCreate($input: CollectionInput!) {
    collectionCreate(input: $input) {
    userErrors {
        field
        message
    }
    collection {
        id
    }
}

 

 

Success Without Publications

 

 

{
   "input":{
      "descriptionHtml":"",
      "handle":"_b67",
      "ruleSet":{
         "appliedDisjunctively":false,
         "rules":[
            {
               "column":"TAG",
               "condition":"_67",
               "relation":"EQUALS"
            },
            {
               "column":"TAG",
               "condition":"_has_image",
               "relation":"EQUALS"
            }
         ]
      },
      "seo":{
         "description":"Test 67",
         "title":"Test 67"
      },
      "publications":[
         
      ],
      "sortOrder":"PRICE_DESC",
      "templateSuffix":"",
      "title":"Test 67"
   }
}

 

 

Fail with Publications

 

 

{
   "input":{
      "descriptionHtml":"",
      "handle":"_b67",
      "ruleSet":{
         "appliedDisjunctively":false,
         "rules":[
            {
               "column":"TAG",
               "condition":"_67",
               "relation":"EQUALS"
            },
            {
               "column":"TAG",
               "condition":"_has_image",
               "relation":"EQUALS"
            }
         ]
      },
      "seo":{
         "description":"Test 67",
         "title":"Test 67"
      },
      "publications":[
         {
            "channelId":"gid://shopify/Channel/70909526170"
         },
         {
            "channelId":"gid://shopify/Channel/76506726554"
         },
         {
            "channelId":"gid://shopify/Channel/76535726234"
         }
      ],
      "sortOrder":"PRICE_DESC",
      "templateSuffix":"",
      "title":"Test 67"
   }
}

 

 

Error

 

 

{
   "data":{
      "collectionCreate":"None"
   },
   "errors":[
      {
         "message":"CollectionCreate access denied",
         "locations":[
            {
               "line":2,
               "column":11
            }
         ],
         "path":[
            "collectionCreate"
         ]
      }
   ],
   "extensions":{
      "cost":{
         "requestedQueryCost":10,
         "actualQueryCost":10,
         "throttleStatus":{
            "maximumAvailable":1000.0,
            "currentlyAvailable":990,
            "restoreRate":50.0
         }
      }
   }
}

 

 

 

Reply 1 (1)
L_J_K
Shopify Staff
367 54 65

Hey @davideagle 

If making that call with an app that isn't a Private app installed on a Plus Store (that holds the Publications Scope) then you'd receive the Access Denied response when trying to include the publications in the CollectionCreate. The Publications scope can be requested via contacting Partner Support.

I can replicate the same response you'd received if I don't have the write publications scope and I call the same mutation with the publication Inputs. Yet I would reasonably expect the the reason above to be returned as opposed to "CollectionCreate access denied" - so the response returned client side could be more user friendly in fairness.

I acknowledge we could make it clearer in the CollectionCreate docs too - we'll work on changing those. Let me know if that helps or if you need more information - thanks!

| API Support @ Shopify |
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!