All things Shopify and commerce
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hello Shopify Community,
I'm having some trouble getting `TaxonomyCategory` nodes of a list of products. When I'm using an authenticated admin request, there is no problem getting them. But once I include `category` in an unauthenticated Storefront request I do receive an error like this.
10:16:47 │ remix │ Could not fetch product data using this params: URLSearchParams { 10:16:47 │ remix │ 'ids' => 'gid://shopify/Product/***********,gid://shopify/Product/********', 10:16:47 │ remix │ 'shop' => '**********' } 10:16:47 │ remix │ [ 10:16:47 │ remix │ { 10:16:47 │ remix │ message: 'Internal error. Looks like something went wrong on our end.\n' + 10:16:47 │ remix │ 'Request ID: e395a16c-33e0-475a-ab49-46720f75647b-1733221006 (include this in support requests).', 10:16:47 │ remix │ extensions: { 10:16:47 │ remix │ code: 'INTERNAL_SERVER_ERROR', 10:16:47 │ remix │ requestId: 'e395a16c-33e0-475a-ab49-46720f75647b-1733221006' 10:16:47 │ remix │ } 10:16:47 │ remix │ } 10:16:47 │ remix │ ]
And I have been trying with multiple access scopes beside the `unauthenticated_read_product_listings` and nothing seems to work. Also I'm using the latest stable ApiVersion (2024-10).
Had anybody encountered a problem like this?
This is the query and once I remove the category fields it's working as expected.
const { storefront, ...rest } = await unauthenticated.storefront(params.get("shop")); const response = await storefront.graphql(` #graphql query GetCategoriesAndCollections($ids: [ID!]!) { nodes(ids: $ids) { ... on Product { id category { id name } collections(first: 250) { nodes { id title } } } } } `, { variables: { ids: params.get("ids").split(","), }, } )
Thank you!
Solved! Go to the solution
This is an accepted solution.
@WilSmithASP Thanks for your comment! I'm glad that I'm not the only one who encountered this problem.
I've been emailing Shopify Support too about this problem, and they responded promptly that even though product details can be returned for unauthenticated requests, TaxonomyCategory is still treated as sensitive data, not sure why, so it can't actually be requested. But it also seems to contradict this published changelog.
----------------
Based on the information you've provided, it seems that the unauthenticated_read_product_listings access scope—which you are currently using—does indeed allow for general product details to be fetched publicly but does not include access to TaxonomyCategory nodes. These nodes are considered more sensitive and are therefore restricted under the unauthenticated public API calls.
---------------
What I'm going to do is set up hooks and track products category/collections per store on my app extension DB. It'll also be much more efficient in terms of latency, no more round trips around the internet.
It seems like the issue is related to the fact that you're trying to fetch the category field in an unauthenticated storefront API request.
The category field might not be available with the unauthenticated_read_product_listings scope, as it could require different access permissions. You might want to check if additional permissions or API scopes are needed for accessing categories.
Additionally, ensure you're using the correct GraphQL query and that the categories field is supported in the unauthenticated context for your specific API version.
Try adjusting the query or permissions to resolve the issue.
Thank @chilblains for your reply.
The category field is available with the `unauthenticated_read_product_listings` scope. It's documented an public in Shopify Storefront API. And it's specially marked that you need `unauthenticated_read_product_listings` so a request can received it, Checkout the documentation here, https://shopify.dev/docs/api/storefront/2024-10/objects/Product#field-category
It seems like it's an internal error on the Shopify end and not my mistake, that's why I posted here.
Thanks again!
I am also experiencing the same issue. Newer API versions are not working either. Just letting you know you are not alone, also following in case someone finds a solution. I will let you know if I find anything
This is an accepted solution.
@WilSmithASP Thanks for your comment! I'm glad that I'm not the only one who encountered this problem.
I've been emailing Shopify Support too about this problem, and they responded promptly that even though product details can be returned for unauthenticated requests, TaxonomyCategory is still treated as sensitive data, not sure why, so it can't actually be requested. But it also seems to contradict this published changelog.
----------------
Based on the information you've provided, it seems that the unauthenticated_read_product_listings access scope—which you are currently using—does indeed allow for general product details to be fetched publicly but does not include access to TaxonomyCategory nodes. These nodes are considered more sensitive and are therefore restricted under the unauthenticated public API calls.
---------------
What I'm going to do is set up hooks and track products category/collections per store on my app extension DB. It'll also be much more efficient in terms of latency, no more round trips around the internet.
also facing this same issue. what’s odd is that if i make the same request using Postman or curl, no errors. but when I try to use the js client or fetch from code, i get an error. it’s almost as if the error is caused by the method of request. A header maybe? i can’t put my finger on it.