Hi, I am developing the backend in python using the Admin API and the Storefront API. But I’m having a problem with the Storefront API. I do everything the documentation says:
-
Create private APP
-
Get the X-Shopify-Storefront-Access-Token and insert it into requests header
-
Get the shop_id and set the requests url to "https://{shop_id}.myshopify.com/api/2021-10/graphql.json"
-
Write a query (for example:
{
products(first:5) {
edges {
node {
id
}
}
}
}
)
- Do a POST request
So far so good, if only he didn’t give me back {‘errors’: ‘Not Found’} for each request with different queries i do.
I hope you can help me
Example code:
#Return the X-Shopify-Storefront-Access-Token
def token(self):
url = self.url + self.__endpoints['storefront']['list']
json = requests.get(url).json()
return json['storefront_access_tokens'][0]['access_token']
#Example query
def graphql(self):
url = "https://%s.myshopify.com/api/2021-10/" % (self.SHOP_ID) + self.__endpoints['graphql']
query= """{
products(first:5) {
edges {
node {
id
}
}
}
}
"""
return requests.post(url, json=query, headers={'X-Shopify-Storefront-Access-Token': self.token()}).json()
# return {'errors': 'Not Found'}