Closed iDonib closed 8 months ago
I'm closing this due to inactivity.
Hey, I have the same issue.
Steps to reproduce:
pnpm init
pnpm i shopify-api-node@latest
Admin API access scopes
: read_products
, read_product_listings
and get your credentialsnode index.js
inserting credentials created in step 3// index.js
const Shopify = require('shopify-api-node');
const shopify = new Shopify({
shopName: 'your-shop',
apiKey: 'your-key',
password: 'your-password',
apiVersion: '2024-04'
});
const main = async () => {
let params = { limit: 250 };
const page = await shopify.collectionListing.list(params);
console.log(page);
};
main();
The error will be:
node:internal/process/promises:289
triggerUncaughtException(err, true /* fromPromise */);
^
HTTPError: Response code 404 (Not Found)
I suspected that this is because the collectionListing
URL does not exist anymore in newest Shopify API versions, but that is not true. Here's what i get if i put a console.log inside buildUrl
function in mixins/base.js
file:
buildUrl(id, query) {
id || id === 0 || (id = '');
let pathname = '/admin';
if (this.shopify.options.apiVersion) {
pathname += `/api/${this.shopify.options.apiVersion}`;
}
pathname += `/${this.name}/${id}`;
pathname = pathname.replace(/\/+/g, '/').replace(/\/$/, '') + '.json';
const url = { pathname, ...this.shopify.baseUrl };
if (query) {
url.search = '?' + qs.stringify(query, { arrayFormat: 'brackets' });
}
console.log(url)
return url;
}
{
pathname: '/admin/api/2024-04/collection_listings.json',
hostname: 'mystore.myshopify.com',
protocol: 'https:',
search: '?limit=250'
}
And that's a real endpoint as Shopify Docs say, but it really returns 404.
I dug a bit deeper and I found out the issue. It really doesn't make ANY sense and it's not shopify-api-node
's fault at all: turning on unauthenticated_read_product_listings
on Storefront API access scopes
on the private app makes everything work as expected. I have really no idea why, since we are making admin calls and Storefront API calls are not involved. That looks a lot like a workaround and I am not sure it is the right solution, but I wanted to share with you.
Below is the error after calling
collectionListing.*()