Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SmartCollection.order Returns 414 if there are too many product IDs #398

Open
JasonZigelbaum opened this issue Jul 22, 2020 · 0 comments
Open

Comments

@JasonZigelbaum
Copy link

JasonZigelbaum commented Jul 22, 2020

This is partly an issue w/ Shopify's documentation but here's a scenario:

shopify.smartCollection.order(id, { products: [...large product id array...] }

If the # of ids is large enough this will generate a very large URL that cannot be processed and returns a 414 response.

This can be resolved by putting the Product ID array in the body instead of in the URL. This is documented (unofficially) here: https://community.shopify.com/c/Shopify-APIs-SDKs/414-Request-URI-Too-Large-error/td-p/269847/page/2

This can be updated by doing something like this in the package:

SmartCollection.prototype.order = function order(id, params) {
  const url = this.buildUrl(`${id}/order`);
  return this.shopify.request(url, 'PUT', undefined, params);
};

I've used the above code locally and it resolves the issue.

That being said I recognize that this isn't documented officially so I understand why the product ids are being appended to the URL instead of being added to the body even though appending to the body is more durable. But for a lot of smart collections, the # of product ids will quickly pile up as you add more items to your store. Perhaps adding a flag would be appropriate so you can chose to append the Product IDs to the body if you run into 414 issues?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant