We encountered a strange behaviour of the AssignedFulfillmentOrder REST API. If you use a filter to retrieve a list of fulfillment orders assigned to the shop location and being submitted, it won't use the filter for assignment_status on of the following result pages of its pagination.
Example
- Make sure to have fulfillment requests in different states. Some of them are in "request_status" = submitted, others are in "unsubmitted".
- Now, let's go to the API and see what we get.
- 1st try: We get a lot of results that are going to be perfectly filtered.
We will filter for:
- our location_id to get the results for our assigned location
- we will filter for assignment_status=fulfillment_requested, because we are a fulfillment service that wants to only fetch orders that are waiting to be fulfilled.
- On our first try we get all the maximum result: limit=250
Our request should look like this:
https://myshop.myshopify.com/admin/api/2023-01/assigned_fulfillment_orders.json?assignment_status=fulfillment_requested&location_ids%5B%5D=12345678&limit=250
- In the response our filter for assignment_status=fulfillment_requested is respected. Though assignment status is not part of the result, it's reflected in request_status. request_status should always be submitted in the results you see.
- 2nd request: In our second try, we are going to limit the resultset to 10 fulfillment orders, to make sure we have paginated results following.
https://myshop.myshopify.com/admin/api/2023-01/assigned_fulfillment_orders.json?assignment_status=fulfillment_requested&location_ids%5B%5D=12345678&limit=10
- The header of the last response shows us the Link attribute (read more here). It provides us with a link to the second result "page". It looks like this:
https://myshop.myshopify.com/admin/api/2023-01/assigned_fulfillment_orders.json?limit=10&page_info=eyTJASD52hjkdaskduihak24asdli56j123
- It does not carry any of the earlier filters because they form part of the page_info. Shopify states in its documentation:
Because the request URL contains the page_info parameter, you can't add any other parameters to the request, except for limit. Including other parameters can cause the request to fail.
- However, when opening this page (or any of the following result pages) we have fulfillment orders that are in request_status unsubmitted.
⚠️ If you're relying on the pagination behaviour here, it can lead to serious damage: Fulfillment orders being fetched that are not yet meant to be fulfilled.
Is there any way to get correct results for our case? How can we make sure our filters are respected in the paginated results?
Thank you
Thomas