How do I get the associated fulfillment service that is associated with a location?

Highlighted
Shopify Partner
15 0 1

Some background: I started seeing a new error when I wanted to change the location of a fulfillment order. Using this API https://shopify.dev/docs/admin-api/rest/reference/shipping-and-fulfillment/fulfillmentorder#move-202...

This was the error I got

```
ActiveResource::ResourceInvalid: Failed. Response code = 422. Response message = Unprocessable Entity (The new location must belong to the same fulfillment service.).
```


I would like to avoid this in the future, so I figure I'd try to only move to locations that have the same fulfillment service. However, I can't seem to find the fulfillment service associated with a location just by querying the location? From the documents: https://shopify.dev/docs/admin-api/rest/reference/inventory/location#show-2020-07

(Note how there is no fulfillment service attribute on the location)

How do I get the associated fulfillment service that is associated with a location?

0 Likes
Highlighted
Shopify Partner
700 53 139

While I'm not sure about using the REST API for this, here is something you could try in the GraphQL API (see below). You can install the GraphiQL App in a Shopify shop to play around with it as well, if you aren't familiar with this particular API. Hope this helps!

{
  locations(first: 5) {
    edges {
      node {
        id
        name
        fulfillsOnlineOrders
        fulfillmentService {
          id
          serviceName
        }
      }
    }
  }
}
0 Likes
Highlighted
Shopify Partner
15 0 1

Thanks for the tip!

Funny thing is, when I tried it with a customer's shop it returned 1 location. While the REST API returned 5 locations.

Looking at the GraphQL query it doesn't look like anything is getting filtered but for some reason I'm not getting all the locations. I wonder why!

 

> results.data.locations.edges.map{|e| e.node.inspect}
#< id="gid://shopify/Location/57516949XXX" name="No. A154 ...," fulfillsOnlineOrders=true fulfillmentService=nil>
=> nil
irb(main):024:0> results.data.locations.edges.size
=> 1

 

0 Likes