A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Solved! Go to the solution
This is an accepted solution.
This does sound like a strange error as the cartCreate mutation is available on the storefront API, but here's a few things you could check to troubleshoot this:
Try the above and let us know if you're still seeing issues.
Liam | Developer Advocate @ 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
This is an accepted solution.
Hey @Umang-panholi ,
Thanks for confirming that. Testing this here, it looks like you're making the cartCreate mutation to the admin api instead of the storefront API. I received the exact same error when I tried cartCreate in the admin api.
You'll want to make sure you're using your storefront access token and authenticating your request as described here: https://shopify.dev/docs/api/storefront#authentication
Once you're making requests to the storefront API, I did notice that your buyer identity fields have some errors (mainly incorrect country and zip). That is going to return some errors as well.
I'd recommend for next steps to start with a very basic mutation, like the one provided below and then slowly add in the fields you need, testing each step of the way to catch those errors!
mutation {
cartCreate(
input: {
lines: [
{
quantity: 1
merchandiseId: "gid://shopify/ProductVariant/11157441773853"
}
]
}
) {
cart {
id
checkoutUrl
}
userErrors {
field
message
}
}
}
Hope that helps!
- Kyle G.
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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
This is an accepted solution.
This does sound like a strange error as the cartCreate mutation is available on the storefront API, but here's a few things you could check to troubleshoot this:
Try the above and let us know if you're still seeing issues.
Liam | Developer Advocate @ 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
I grant all permissions but it isn't working.
This is an accepted solution.
Hey @Umang-panholi ,
Thanks for confirming that. Testing this here, it looks like you're making the cartCreate mutation to the admin api instead of the storefront API. I received the exact same error when I tried cartCreate in the admin api.
You'll want to make sure you're using your storefront access token and authenticating your request as described here: https://shopify.dev/docs/api/storefront#authentication
Once you're making requests to the storefront API, I did notice that your buyer identity fields have some errors (mainly incorrect country and zip). That is going to return some errors as well.
I'd recommend for next steps to start with a very basic mutation, like the one provided below and then slowly add in the fields you need, testing each step of the way to catch those errors!
mutation {
cartCreate(
input: {
lines: [
{
quantity: 1
merchandiseId: "gid://shopify/ProductVariant/11157441773853"
}
]
}
) {
cart {
id
checkoutUrl
}
userErrors {
field
message
}
}
}
Hope that helps!
- Kyle G.
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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
your code is correct but it is work on storefront side...