Recommendation API with net 7

Topic summary

A developer integrating Shopify products into a .NET 7 application encountered a “forbidden” error when attempting to use Shopify’s recommendation endpoint via their custom app’s API.

Solution provided:

  • Switch from the standard API to the Storefront API, which is specifically designed for product recommendations rather than the AJAX API used in Liquid stores.

Implementation issues:

  • Initial attempts with the productRecommendations GraphQL query from documentation failed with “Field ‘productRecommendations’ doesn’t exist on type ‘QueryRoot’” error.
  • Testing simpler queries (like getProductById) from the same documentation worked fine.

Resolution:

  • After making corrections and properly configuring the Storefront API, the developer successfully resolved all issues and got recommendations working.
Summarized with AI on November 14. AI used: claude-sonnet-4-5-20250929.

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}”;

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.

Hey @SBD ,

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

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.

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

1 Like