Skip to content

404 error migrating from ProductService to GraphQL query. #1177

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

Open
jeleleven opened this issue Apr 28, 2025 · 2 comments
Open

404 error migrating from ProductService to GraphQL query. #1177

jeleleven opened this issue Apr 28, 2025 · 2 comments
Labels

Comments

@jeleleven
Copy link

jeleleven commented Apr 28, 2025

Hello @nozzlegear,

Thank you for your work on this. It's been very useful.

As I understand it, ProductService has been depreciated and I will need to move over to GraphQL going forward.

I am working on moving my code over to GraphQL, but I'm getting a 404 error when I use the sample code. The issue is happening at the PostAsync call, returning a '404 Not Found' HttpException.

I am able to use the following code to retreive all products from our store without issue:
var productService = new ProductService(shopifyUrl, apiToken)

When I use the sample code, it does not work:

var graphService = new GraphService(shopifyUrl, apiToken);

var graphRequest = new GraphRequest
{
    Query =
        """
        query {
            products(first: 3, query: "status:ACTIVE") {
                pageInfo {
                    startCursor
                    endCursor
                    hasNextPage
                    hasPreviousPage
                }
                nodes {
                    id
                    # Get the product's REST Id too
                    legacyResourceId
                    title
                    handle
                    hasOnlyDefaultVariant
                    variantsCount {
                        count
                    }
                }
            }
        }
        """,
}

var graphResult = await graphService.PostAsync<Shopify_API_Classes.ListProductsResult>(graphRequest)

I have verified that my shopifyUrl variable is the *.myshopify.com url, as was noted in the Wiki.

Do you see something I may be missing here?

Thanks!

@nozzlegear
Copy link
Owner

Hey @jeleleven! Did you get this working yet? I don't see anything wrong with it at first glance. The GraphQL API endpoint doesn't typically return a 404 status code for normal operations, even if a resource doesn't exist. Instead it would return an error message with a 200 OK status code. The 404 suggests that something is wrong with the Shopify URL itself – is it possible there's a typo?

@jeleleven
Copy link
Author

jeleleven commented May 5, 2025

Hey @jeleleven! Did you get this working yet? I don't see anything wrong with it at first glance. The GraphQL API endpoint doesn't typically return a 404 status code for normal operations, even if a resource doesn't exist. Instead it would return an error message with a 200 OK status code. The 404 suggests that something is wrong with the Shopify URL itself – is it possible there's a typo?

I don't believe there's anything wrong with the shopify URL since it works with ProductService.

Image

EDIT:

I have dug a little deeper using curl and found that the 404 error is happening at this URL: https://myURL.myshopify.com/admin/api/2024-10/graphql.json

According to this page, I found the issue. My shop domain is redirected to a different URL. When I use that redirected URL, it works fine.

Sorry to trouble you with this.

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

No branches or pull requests

2 participants