Hi community,
I’m experiencing issues when trying to retrieve information from the localizationExtensions object of a request using the GraphQL API in a C# application. To access the API, I’m utilizing the GraphQL.Client package available on NuGet.
The error I receive when requesting the data is: “The HTTP request failed with status code ‘NotFound’”.
What leads me to suspect that the problem may not lie within my application is the fact that I have two Shopify stores. One of them is dedicated to development and is somewhat “raw,” with no apps except for the development one. This development store contains the Admin API with the necessary scopes enabled. Let’s refer to it as the development store. Additionally, there is the client’s store with the Admin API app, which has the same selected scopes but in a more commercial environment and is considered the “active” store.
In my development store, I can consume the GraphQL API without any issues. However, the error only occurs in the client’s store.
In the client’s store, I installed the Shopify GraphiQL app, which allows me to execute queries within the platform itself. I attempted to make the same query that I used in my application and succeeded, indicating that the endpoint exists in some way for the order ID I’m attempting to query.
Could the account I used to create the API app be a factor in this? I’m asking because I observed that some scopes are locked in the selection of Admin API access scope for the user I used to create the client’s app on Shopify.
Has anyone encountered a similar issue or knows how to assist me?
Here is my code:
public OrderTaxIdService(string shopifyUrl, string accessToken)
{
_graphQLClient = new GraphQLHttpClient($"{shopifyUrl}/admin/api/2023-07/graphql.json", new NewtonsoftJsonSerializer());
_graphQLClient.HttpClient.DefaultRequestHeaders.Add("X-Shopify-Access-Token", accessToken);
}
public async Task<string> GetAsync(string adminGraphQLAPIId)
{
var orderRequest = new GraphQLRequest
{
Query = @"
query getOrder($id: ID!) {
order(id: $id) {
id
localizationExtensions(first: 1) {
edges {
node {
title
value
}
}
}
}
}",
Variables = new { id = adminGraphQLAPIId }
};
var orderResponse = await _graphQLClient.SendQueryAsync<OrderResponseType>(orderRequest);
var node = orderResponse.Data.Order.LocalizationExtensions.Edges.FirstOrDefault(e => e.Node.Title == "CPF/CNPJ");
return node?.Node.Value ?? string.Empty;
}
Query:
{
order(id: "gid://shopify/Order/5508188832050") {
id
localizationExtensions(first: 1) {
edges {
node {
title
value
}
}
}
}
}
Many thanks for your support.