Solved

App Data Missing from API Calls

mitchjs
Tourist
5 0 2

My company had a developer make an app that used the Shopify API that is no longer employed by this company and it has worked for a few years without issue. However, we've been getting emails from our app saying that it is missing required data to import an order from Shopify into our in-house order/quoting system.

I traced the issue down to being a blank 'Source' value within the Orders > shipping_lines resource. From my research, it doesn't look like this part the naming convention for the API responses has changed at all since the app was written, am I correct that this part hasn't changed?

If that is correct, then what could be causing the Source value to be missing? How does the order get this value and where can I verify its integrity?

I am very new to using Shopify, so my knowledge is a bit spotty. Any help is greatly appreciated.

Accepted Solution (1)
ShopifyDevSup
Shopify Staff
1440 235 489

This is an accepted solution.

Hey @mitchjs - no worries, thanks for getting back in touch.  I was able to run a similar CURL command in my terminal (used your formatting, but just swapped in my shop/credentials) and it worked for me. I also tested the command in Postman (an API Client) - and was able to receive the requested JSON payload. Could you try the query in an API client and let us know if the query goes through? Here's a link to Postman or Insomnia, which is another great client, especially for GraphQL. Requests in these client should also include response headers, which would have an "X-Request-ID" field. 

If you encounter any errors in the client - just share one of those requests IDs and we can take a look at the logs on our end to see if we're able to help further. Hope this helps - let us know if we can clarify anything further.

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 6 (6)

ShopifyDevSup
Shopify Staff
1440 235 489

Hi @mitchjs 👋

Without knowing what and how your custom app is meant to "import" data (this could be using a direct REST/GraphQL Admin API request or one of the order-related webhooks), it's unclear what could be causing this issue. Generally, the shipping line source of an order is the provider of the quoted shipping rate. Keep in mind that our Admin API is versioned quarterly, and changes are announced a year in advance in case migrations are required. 

 

I'd recommend working with a developer who can review the app's source code and identify the culprit. You can share the below reference docs with the developer as a good place to start as well:

 

- order-related webhooks

- Admin REST API order resource

- Admin GraphQL API order object

 

Hope that helps!

 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

mitchjs
Tourist
5 0 2

Thanks for the reply!

I am actually the developer working on fixing this app. The Admin REST API Order Resource is actually where I identified the field, it's this one:

mitchjs_0-1674065738962.png


What I would like to know is where in the order process does that source value get assigned? Once I know that, I should be able to figure out where in the pipeline that the value is going missing.

I'm glad to hear that y'all have such a transparent versioning process, which reassures me that this app should still work, it's just a matter of this one field.

The way the app works is that it retrieves the shipping_lines resource from a network request, what that request is I'm not certain. It then uses the source and code values to lookup the carrier, which it then transmits to our quoting program, assuming that check passes.

The code comes through correctly as 'USPSFirstClass', and I believe the source value should be 'usps' which maps to carrier 'USPS-First Class Mail'. However, since the source is blank, the query fails and returns no carrier.

ShopifyDevSup
Shopify Staff
1440 235 489

In that case, it may be best to connect with us here using an account that has permissions to this store, so that we can take a closer look at the actual orders. Order that do not require shipping (digital products, gift cards, etc.) would not have any shipping lines, so we would need to take a look at actual examples of orders where only the shipping line source is missing. 

 

I'd recommend using the below query to identify all orders with a non-null `shippingLine.id` but has `shippingLine.source` as null. Please be sure to provide this list to the team to be included in the ticket.

 

{
    orders (first: 250, reverse: true){
        nodes {
            id
            shippingLine {
                id
                source
            }
        }
    }
}

 

Below is the curl request for your convenience:

 

curl -L -X POST 'https://STORE_NAME.myshopify.com/admin/api/2023-01/graphql.json' \
-H 'X-Shopify-Access-Token: ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
--data-raw '{"query":"{ orders (first: 250, reverse: true){ nodes { id shippingLine { id source } } } }","variables":{}}'

 

 

 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

mitchjs
Tourist
5 0 2

Apologies for the delay, it took me a while to figure out who had the access credentials.

So turns out the app I'm working with doesn't use an access token from this storefront? Or at least, I'm not sure. It doesn't show up in the list of apps for this site, but it works just fine (aside from the obvious error), as such I don't have that access token.

So, I made a new one, but I'm having issues with running that CURL command.

curl -L -X POST 'https://farm-equipment-parts.myshopify.com/admin/api/2023-01/graphql.json' -H 'X-Shopify-Access-Token: ACCESS_TOKEN' -H 'Content-Type: application/json' --data-raw '{"query":"{ orders (first: 250, reverse: true){ nodes { id shippingLine { id source } } } }","variables":{}}'


The errors I'm getting are:

 

curl: (3) URL using bad/illegal format or missing URL
curl: (6) Could not resolve host: ACCESS_TOKEN
curl: (6) Could not resolve host: application


For the record, I did actually use the new access token I generated, I'm just not sharing it here for obvious reasons.

I did some digging and I tried changing all the {'} to {"} and instead I get:

Bad Requestcurl: (6) Could not resolve host: orders
curl: (3) URL using bad/illegal format or missing URL
curl: (6) Could not resolve host: 250,
curl: (3) URL using bad/illegal format or missing URL
curl: (3) unmatched brace in URL position 6:
true){
     ^


It's been quite a while since I've had to use CURL in any capacity (4, 5 years?) so I'm a bit lost as to what's going on.

I would put the ticket into the site you directed me to, but I don't have the data to send them.

ShopifyDevSup
Shopify Staff
1440 235 489

This is an accepted solution.

Hey @mitchjs - no worries, thanks for getting back in touch.  I was able to run a similar CURL command in my terminal (used your formatting, but just swapped in my shop/credentials) and it worked for me. I also tested the command in Postman (an API Client) - and was able to receive the requested JSON payload. Could you try the query in an API client and let us know if the query goes through? Here's a link to Postman or Insomnia, which is another great client, especially for GraphQL. Requests in these client should also include response headers, which would have an "X-Request-ID" field. 

If you encounter any errors in the client - just share one of those requests IDs and we can take a look at the logs on our end to see if we're able to help further. Hope this helps - let us know if we can clarify anything further.

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

mitchjs
Tourist
5 0 2

That did the trick! Thanks for the help! I used this to narrow down the order id of the most recent error and sent the order data for that order to the support website you linked me to.