Hi, I tried to publish our products into our private App with publishablePublish.
The app-name is "checkout" and access scope "write_publications" had been enabled.
But I always get the error message as below :
{
"errors": [
{
"message": "Parse error on \"id\" (STRING) at [5, 11]",
"locations": [
{
"line": 5,
"column": 11
}
]
}
]
}
I call this API with curl as below :
PS :
1111111111 is the password of the app "checkout"
2222222222 is "shopify_product_id" of the product which will be published into the app "checkout"
3333333333 is the API key of the app "checkout"
curl -X POST \
"https://<shop>.myshopify.com/admin/api/2020-04/graphql.json" \
-H "Content-Type: application/graphql" \
-H "X-Shopify-Access-Token: 1111111111" \
-d '
{
mutation {
publishablePublish(
"id": "gid://shopify/Product/2222222222",
"input": [
{
"channelId": ["3333333333"]
}
]
) {
publishable {
availablePublicationCount
publicationCount
publishedOnCurrentPublication
}
shop {
id
}
userErrors {
field
message
}
}
}
}
'
I was wondering whether the syntax and arguments are correct or not?
If not, how do I use it in correct?
Hey @edem
Looks like a few syntax errors. Try something like:
mutation publishablePublish { publishablePublish( id: "...", input: [ {} ] ) { publishable { availablePublicationCount publicationCount publishedOnCurrentPublication } shop { id } userErrors { field message } } }
Or pass the arguments separately, here's an example. Also, channelId is deprecated, you can use publicationId instead.
I am confused about the arguments of publishablePublish.
Should "X-Shopify-Access-Token be the password of channels or apps ?
Should "$id" be shopify_product_id of the product like
"gid://shopify/Product/4508468510833"
Should "publicationId" be the API-Key of channels or apps, like
publicationId : "51aea2192fb946dc5737f970caadb332"
Hi, I try this :
curl -X POST \
"https://citiesocial.myshopify.com/admin/api/2020-04/graphql.json" \
-H "Content-Type: application/graphql" \
-H "X-Shopify-Access-Token: <password of app>" \
-d '
{
mutation publishablePublish {
publishablePublish(
id: "gid://shopify/Product/<shopify_product_id>",
input: [
{}
]
) {
publishable {
availablePublicationCount
publicationCount
publishedOnCurrentPublication
}
shop {
id
}
userErrors {
field
message
}
}
}
}
'
and this :
curl -X POST \
"https://citiesocial.myshopify.com/admin/api/2020-04/graphql.json" \
-H "Content-Type: application/graphql" \
-H "X-Shopify-Access-Token: <password of app>" \
-d '
{
mutation publishablePublish {
publishablePublish(
id: "gid://shopify/Product/<shopify_product_id>",
input: [
{
publicationId : "<API-key of app>"
}
]
) {
publishable {
availablePublicationCount
publicationCount
publishedOnCurrentPublication
}
shop {
id
}
userErrors {
field
message
}
}
}
}
'
But I got the error message :
{"errors":[{"message":"Field 'mutation' doesn't exist on type 'QueryRoot'","locations":[{"line":3,"column":5}],"path":["query","mutation"],"extensions":{"code":"undefinedField","typeName":"QueryRoot","fieldName":"mutation"}},{"message":"Field 'publishablePublish' doesn't exist on type 'QueryRoot'","locations":[{"line":3,"column":14}],"path":["query","publishablePublish"],"extensions":{"code":"undefinedField","typeName":"QueryRoot","fieldName":"publishablePublish"}}]}
The syntax seems correct but invalid global id.
The field pbulicationId should be API-Key of app, doesn't it?
curl -X POST \
"https://<shop>.myshopify.com/admin/api/2020-04/graphql.json" \
-H "Content-Type: application/graphql" \
-H "X-Shopify-Access-Token: <password of app>" \
-d '
mutation {
publishablePublish(
id: "gid://shopify/Product/4508468510833",
input: [
{
publicationId : "51ae........................"
}
]
) {
publishable {
availablePublicationCount
publicationCount
publishedOnCurrentPublication
}
shop {
id
}
userErrors {
field
message
}
}
}
'
The error message :
{"errors":[{"message":"Invalid global id '51ae.......................'","locations":[{"line":6,"column":17}],"path":["mutation","publishablePublish","input",0,"publicationId"],"extensions":{"code":"argumentLiteralsIncompatible","typeName":"CoercionError"}}]}
User | Count |
---|---|
16 | |
12 | |
7 | |
6 | |
5 |