A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hello. I am creating a product, it's metafield, and image using the Admin API. I want to return a URL to the cart with the product selected and a quantity of 1.
This is the response of the POST Product request /admin/api/2021-10/products.json:
It looks like there is one default variant.
Following the example in the documentation here: https://shopify.dev/custom-storefronts/cart#create-a-cart-and-add-a-line-item
I receive this error:
I don’t have all the context, but it feels like you are creating a product with the REST API, but and then using the storefront API to create carts.
The IDs differ between REST and GraphQL. Did you take a look in the docs?
There’s examples of Global IDs (GIDs) in here that should give you some inspiration:
https://shopify.dev/api/admin/getting-started
Looking at the reply in REST, you also see the a GID in the data returned (see admin_graphql_api_id property)
Your asumptions are correct. I guess I should just use the GraphQL interfaces and forget about the REST interfaces
I switched to using the admin graphql api and I am able to create the cart and get a working url now! But I had to query the store for the legacy id of the default variant so that I could upload the custom photo of the product as 64bit encoded image because that feature doesn't exist in the graphql api. So the only problem I have left to solve is how do I automatically select my app in the sales channels and apps when I create the product using the admin graphql api?