Error-Invalid Id while syncing a product to a channel

WPD
Visitor
2 0 1

Hi ,  I am trying to sync a product from shopify to a sales channel using graphQL but it always gives an error saying invalid ID. But I checked both ,the channel id and the product ID,  are correct. Below is a code snippet. Can anyone suggest something ?

mutation publishablePublish {
    publishablePublish(
        id: "gid://shopify/Product/[ProductID]",
        input: [
          {
            publicationId : "gid://shopify/Apps/[ChannelID]" 
          }
        ]
    ) {
        publishable {
            availablePublicationCount
            publicationCount
            publishedOnCurrentPublication
        }
        shop {
            id
        }
        userErrors {
            field
            message
        }
    }
}

 

Replies 4 (4)

cquinterom096
Shopify Partner
3 0 1

I have this exact problem, did you find the solution?

sanabns
New Member
11 0 0

Got the solution for this?

WPDiamonds
Visitor
1 0 0

I think we had to talk to support and get the publication api turned on.

cquinterom096
Shopify Partner
3 0 1

I also had to contact support to activate the following scope: write_publications.

However, even with that I kept getting the invalid ID issues. I tried multiple IDs similar to yours, but none seemed to work. Contacted support again to see if they could help me with the ID format, but for some reason this is out of their area of support. The issue seems to be in the resource ID not the channel ID according to my testing.

I'll post my workaround, but as a disclaimer this isn't the ideal solution
Programming Language Ruby 2.3.4 and the Shopify gem 4.12.0

Alternative GraphQl Mutation: PublishablePublishToCurrentChannel

cquinterom096_0-1604339879399.png

Requires: 

  1. Product ID Format: "gid://shopify/Product/<product_id>"
  2. CurrentChannel: Private App used to initialize the Shopify gem or authenticate through the ShopifyAPI.  (this is where it differs with PublishablePublish mutation where the private app ID is passed as an argument).

Why is this not an ideal solution? Because it forces you to reinitialize the Shopify gem (and ShopifyAPI::GraphQl module, which is expensive). Anyway, since the ShopifyAPI Gem is thread safe I delegated this mutation to a background job and had no issues so far.