I’m having issues with the ‘collects’ endpoint when using the API.
I am trying to add a product to a custom collection using the following curl:
curl 'https://{{api_key}}:{{api_password}}@{{store_name}}.myshopify.com/admin/api/2023-01/collects.json' \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {{access_token}}' \
-d '{
"collect": {[
"product_id": {{product_id}},
"collection_id": {{collection_id}}
]}
}'
I can confirm that I am using the correct keys and password etc, as calls to other endpoints work fine. I have write_products and read_products accesses.
The API returns the following:
<html>
<body>
<noscript>
<a
href="https://accounts.shopify.com/oauth/authorize?client_id=xxxxxx&destination_uuid=xxxxx&nonce=xxxx&prompt=merge&redirect_uri=https%3A%2F%2Fxxxxxxx.myshopify.com%2Fadmin%2Fauth%2Fidentity%2Fcallback&response_type=code&scope=email%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fdestinations.readonly%20openid%20profile%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.collaborator-relationships.readonly%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fbanking.manage%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fmerchant-setup-dashboard.graphql%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fshopify-chat.admin.graphql%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fflow.workflows.manage%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Forganization-identity.manage&state=xxxxxx&ui_locales=en&ux=shop">Continue</a>
</noscript>
<script type="text/javascript" defer>
window.location = "https:\/\/accounts.shopify.com\/oauth\/authorize?client_id=xxxxxx\u0026destination_uuid=xxxx\u0026nonce=xxxx\u0026prompt=merge\u0026redirect_uri=https%3A%2F%2Fxxxxxx.myshopify.com%2Fadmin%2Fauth%2Fidentity%2Fcallback\u0026response_type=code\u0026scope=email%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fdestinations.readonly%20openid%20profile%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.collaborator-relationships.readonly%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fbanking.manage%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fmerchant-setup-dashboard.graphql%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fshopify-chat.admin.graphql%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Fflow.workflows.manage%20https%3A%2F%2Fapi.shopify.com%2Fauth%2Forganization-identity.manage\u0026state=xxxx\u0026ui_locales=en\u0033xz=shop";
</script>
</body>
</html>
Any ideas what I am doing wrong?