Why is the section_id required when I get product recommendations

vincentlee
New Member
2 0 0

From the Recommendations API docs, I see that I can get the product recommendations back in two formats depending on the query parameters

  • product_id with no section_id returns JSON 
  • product_id with section_id returns HTML 

https://shopify.dev/docs/themes/ajax-api/reference/product-recommendations#get-recommendations-produ...

I'm having trouble with the JSON response format -- I receive an error response telling me that the section_id parameter is missing

Without section_id 

Query: 

https://mill-and-commons.myshopify.com/recommendations/products?product_id=6212544266414&limit=4

Response: 

Screen Shot 2021-01-09 at 1.57.12 PM.png

The HTML response comes as expected 

With section_id

Query:

https://mill-and-commons.myshopify.com/recommendations/products?product_id=6212544266414&limit=4&sec...

Response: 

with-section-id-response.png

 

0 Likes
dlisi
New Member
1 0 0

To get the JSON object you need to append .json to the endpoint. In your case the AJAX request would be

https://mill-and-commons.myshopify.com/recommendations/products.json?product_id=6212544266414&limit=...

0 Likes