Hello everyone!
It’s the first time I’m testing the API requests for Shopify, trying to test product creation and inventory management (still at the part where I try to get any response from my webstore). I created a new Shopify app like advised, set up the Admin API access scopes to and got access to my token, key and secret key.
I first tried testing via cURL requests and always got 404s
curl -X POST \
https://SHOPNAME.myshopify.com/admin/api/2024-07/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {TOKEN}' \
-d '{
"query": "query { products(first: 2, reverse: true) { edges { node { id title handle resourcePublicationOnCurrentPublication { publication { name id } publishDate isPublished } } } } }"
}'
results in:
{"errors":"Not Found"}%
And also using python:
import requests
import json
shop_credentials = 'shop_credentials.json'
with open(shop_credentials) as f:
shop_credentials = json.load(f)
domain = 'https://SHOPNAME.myshopify.com'
endpoint = '/admin/api/2024-07/graphql.json?'
product_fields = 'limit=2'
base_url = domain + endpoint + product_fields
header_values = {'Content-Type':'application/json','X-Shopify-Access-Token':shop_credentials['api_token']}
get_products = requests.get(base_url, headers = header_values)
print(get_products)
print(get_products.url)
print(get_products.text)
results in:
<Response [404]>
https://SHOPNAME.myshopify.com/admin/api/2024-07/graphql.json?limit=2
{"errors":"Not Found"}
There must be something I am missing out on. What do you think is the most likely cause?
And is the following documentation still relevant?
https://shopify.dev/docs/api/admin-rest/2024-01/resources/product#resource-object
https://shopify.dev/docs/api/admin-graphql/2024-01/queries/products
Thank you so much!!