Our fetch_stock endpoint has stopped working

Solved
Highlighted
Excursionist
13 2 1

Hi all,

Sorry for the vague title, and I'd appreciate any help with this.

For some unknown reason, Shopify has ceased calling our /fetch_stock.json endpoint recently. This is the case for both hourly and individual product updates. The last successful hourly update was at 2020-09-07 09:25 UTC.

Our fetch_stock.json endpoint is working as expected and hasn't changed recently.

I contacted Shopify live chat support, and they confirmed for me that our Shopify store is still making calls to the fetch_stock endpoint, although they didn't confirm if the requests were successful or otherwise.

Additionally, I tried creating a new Fulfillment Service in our Shopify store, and tried to sync the managed inventory, but alas, no success.

Fulfillment Service

 

{
    "id": 00000000000,
    "name": "Hello world",
    "email": null,
    "service_name": "Hello world",
    "handle": "hello-world",
    "fulfillment_orders_opt_in": false,
    "include_pending_stock": false,
    "provider_id": null,
    "location_id": 00000000000,
    "callback_url": "https://api.myapp.com/v1",
    "tracking_support": true,
    "inventory_management": true
}

 

 

Fetch Stock Endpoints

This is an unauthenticated endpoint; and the following query parameters are ignored: max_retries, and timestamp.

https://api.myapp.com/v1/fetch_stock.json?shop=myshop.myshopify.com  

 

{
  "AB01": 1000,
  "AB02": 1000
}

 

https://api.myapp.com/v1/fetch_stock.json?shop=myshop.myshopify.com&sku= AB01

 

{
  "AB01": 1000
}

 

The endpoints work fine when requesting them through a web browser, but I can't verify the requests through Shopify.

0 Likes
Highlighted
Excursionist
13 2 1
Highlighted
Excursionist
13 2 1

This is an accepted solution.

It appears that Shopify has changed (without notice) how the fulfillment service callback URLs work. The base path/context root is stripped from the defined URL on the fulfillment service entity.

I have added an additional route to our API gateway to handle this new case.

Routes:

Shopify seems to successfully request the fetch_stock endpoint through the new route ("...com/fetch...").

The callback URL on our fulfillment service entity is unchanged, and set as:

 

"callback_url": "https://api.myapp.com/v1",

 

Everything now works again for us, and I hope Shopify corrects this issue, as base paths allow for more flexibility.

 

Edit: You may need to change your callback_url to remove multiple directories. I suspect directory slashes are not removed, so a callback_url value of "https://api.myapp.com/v1/v2/v3" may be parsed as "https://api.myapp.com///", and I further suspect that a trailing slash is optional.

1 Like
Highlighted
Shopify Staff
Shopify Staff
587 72 130

Hey @alanguerin,

Thanks for bringing this up. The change in behaviour you mentioned was unintended, and our developers are currently working to restore the previous behaviour. I'll post back here once the previous behaviour is restored.

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
587 72 130

For anyone following, this change in how Shopify handles the fetch_stock callback was unintentional, and our developers are currently working on a fix. I will post an update here when the issue is resolved: https://community.shopify.com/c/Shopify-APIs-SDKs/Our-fetch-stock-endpoint-has-stopped-working/m-p/8...

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

1 Like
Highlighted
Shopify Partner
18 1 1

Hi,

In my case it wasn't that the path some being stripped completely, but just the last sub directory was.

Here's how I fixed it: https://community.shopify.com/c/Shopify-APIs-SDKs/Haven-t-received-a-single-fetch-stock-request-in-t...

Thanks

0 Likes
Highlighted
New Member
2 0 0

This topic had been marked as solved, but is is not.

We are experiencing the same issue with all of our installations for our customers. The solution written above, does not work for our app. 

We get a lot of complains about this, but it is Shopify's fault. After a lot of debugging and testing, it seems that we provide the correct response, but Shopify does not save the actual stock level given in the response.

PLEASE SHOPIFY, SOLVE THIS ASAP!?

0 Likes
Highlighted
Shopify Partner
18 1 1

Hi @ShopWeDo,

Have you got an example of your callback_url you could share?

I was also having issues and I had to do something slightly different to the suggestion above.

I wrote how I fixed it for our case in the link I posted above.

0 Likes
Highlighted
New Member
2 0 0

Hi @chappersjr 

 

In our case, the path works fine. I see in our logs that Shopify fetches the data to the correct path and we indeed send the correct json data in response exactly as the documentation says.

The issue is, that Shopify does not save this response in de stock level of the product or the variant.

0 Likes
Highlighted
Shopify Partner
18 1 1

@ShopWeDo Ok, sounds like a different issue to what was originally described in this post.

The only thing I can suggest is creating a new post describing your issue.

Include a typical response and timings and I'm sure someone will get back to you.

1 Like