Recommendation API with net 7

Solved

Recommendation API with net 7

Yevhen_Bardyn
Shopify Partner
4 0 1

Hi, So i'm going to use shopify as a storage for my products, I'm going to retrieve them by API in my .net app, I've created custom shopify app for it, retrieved access token and all seems to work as expected.

Except the recommendation endpoint, I'd like shopify to also return a recommended products for given product but when I call recommendation endpoint it returns me "forbidden".

Here the endpoint that I'm trying to call:
string apiUrl = $"{usersMyShopifyUrl}recommendations/products.json?product_id={product.Items.FirstOrDefault().Id}";

Accepted Solution (1)

SBD_
Shopify Staff
1829 271 414

This is an accepted solution.

Hey @Yevhen_Bardyn 

 

You'll probably have more luck with the Storefront API instead of the AJAX API which is specifically designed for liquid stores to hit.

Scott | Developer Advocate @ Shopify 

View solution in original post

Replies 4 (4)

SBD_
Shopify Staff
1829 271 414

This is an accepted solution.

Hey @Yevhen_Bardyn 

 

You'll probably have more luck with the Storefront API instead of the AJAX API which is specifically designed for liquid stores to hit.

Scott | Developer Advocate @ Shopify 

Yevhen_Bardyn
Shopify Partner
4 0 1

Hey @SBD_ ,

Thanks for advice!
I'll try with Storefront API, and leave the results here.

Yevhen_Bardyn
Shopify Partner
4 0 1

So I've tried to use this object (copied straight from documentation):

 

query productRecommendations($productId: ID!) {
  productRecommendations(productId: $productId) {
    id
  }
}

 

 But graphQL returns the following error:

 

Field 'productRecommendations' doesn't exist on type 'QueryRoot'

 

I'm not sure what I'm missing here.
Additionally, I tried to use simple:

query getProductById($id: ID!) {
  product(id: $id) {
    title
  }
}

From the same documentation and it worked just fine.

Yevhen_Bardyn
Shopify Partner
4 0 1

I made a few errors and wasn't really using storefront api, but after a few fixes everything works.
Thanks @SBD_ !