Error "invalid id" when trying to add product to sales channel

Solved

Error "invalid id" when trying to add product to sales channel

Andrea49
Visitor
3 1 1

I am trying to add a product to a sales channel using Graphql Admin API, this is my request:

 

 

mutation MyMutation {
    productPublish(input: {id: "%s", productPublications: {publicationId: 
    "gid:\/\/shopify\/Channel\/84635386114"}}) 
    {
        userErrors {
            field
            message
        }
    }
}

 

 

 

When I try to add it, I get this error 

 

 

{"data":{"productPublish":null},"errors":[{"message":"invalid id","locations":[{"line":4,"column":17}],"path":["productPublish"]}],"extensions":{"cost":{"requestedQueryCost":10,"actualQueryCost":1,"throttleStatus":{"maximumAvailable":1000.0,"currentlyAvailable":999,"restoreRate":50.0}}}}

 

 

 

Do you have any idea why I get this error?
I request the channel Id and this is the response

 

 

{"data":{"channels":{"nodes":[{"id":"gid:\/\/shopify\/Channel\/84635386114","supportsFuturePublishing":true}]}},"extensions":{"cost":{"requestedQueryCost":12,"actualQueryCost":3,"throttleStatus":{"maximumAvailable":1000.0,"currentlyAvailable":997,"restoreRate":50.0}}}}

 

 

And I'm sure the product id is correct

 

Accepted Solution (1)
Andrea49
Visitor
3 1 1

This is an accepted solution.

Thanks, I was able to resolve the issue but just adding {published: true} to the productCreate() mutation input, and it was published to my online store

View solution in original post

Replies 2 (2)

Alan
Shopify Staff
129 15 24

Hey @Andrea49 - this is odd. Would you be able to share an X-Request ID from the response headers on the latest request that returns that error? Happy to look into this further with you. 

 

Hope to hear from you soon - let us know if we can clarify anything on our end. 

Alan | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Andrea49
Visitor
3 1 1

This is an accepted solution.

Thanks, I was able to resolve the issue but just adding {published: true} to the productCreate() mutation input, and it was published to my online store