Issues with FulfillmentOrder REST API

Solved
Highlighted
Tourist
4 0 0

Hello,

I'm developing an algorithm to set the locations for line items in order to achieve a minimal shipping cost. First I define the best "line items - location" combination and calculate the shipping cost, then I create an order and try to set the locations for the line items according to the calculated combination. 

I try to do this through FulfillmentOrders by 

- getting the fulfillment orders with GET /admin/api/2020-04/orders/{order_id}/fulfillment_orders.json request

- find the line item that is to be fulfilled from a wrong location and perform a POST /admin/api/2020-04/fulfillment_orders/{fulfillment_order_id}/move.json request

- loop until every line item is bound to a correct location.

This might not be the best solution, but it's the only one I came up with to keep product inventories managed by Shopify.

 

With this being said, the issue is as follows:

After multiple iterations of moving variants from fulfillment order to a different location, I receive only fulfillment orders with status "closed" from the GET request. I suspect that there's some limit of fulfillment orders i can receive from a GET request, so I receive only old ones and the new ones (with status "open") get "cropped" somehow and I can't proceed moving the variants because I can't get the open fulfillment orders id.

 

I'll be grateful for any advice on this issue.

Ksenia

0 Likes
Highlighted
Excursionist
26 4 3

This is an accepted solution.

Hello,

yes you are right. there is a limit in shopify which is 250 orders on one page.

please use paging in your query.

if you are using rest api version "2019-04" then you can just add pag tag in your query like this

".json?limit=250&page=1" but if you are using new api link then you must need to use Cursor-based pagination which you can find in shopify rest api documentation.

Thanks

1 Like
Highlighted
Tourist
4 0 0

Thanks @msk, even just setting the limit to 250 helped to receive the open fulfillment orders.

0 Likes