Fulfillment API returning 404

Solved
Greg_Kujawa
Shopify Partner
1016 83 219
Makes sense in terms of the workflow. So when you are hitting the fulfillment accept endpoint, you are referencing the fulfillment order ID not the order ID, correct? These are two different values and you need to include the fulfillment order ID in the URL. This value should’ve been sent out in the original request you receive.
0 Likes
Ahsan3
New Member
20 0 0

You got it correct, I am using the fulfillment order Id that I received in the original request. This is the exact fulfillment order id that shows in the store URL as well. So once again here is my latest acceptance request. What parameter or process am I missing. I have been struggling with it for the last 3 days. Can't send acceptance, can't send rejection:

x-request-id: c8c0efab-dc49-4143-8e4d-24b6a06466c4

$fulfillment_request = [
"fulfillment_request" => [
"message" => "We will start processing your fulfillment on the next business day.",
]
];

$SHOPIFY_API = "https://$API_KEY =>$PASSWORD@$SHOP_URL//admin/api/2021-01/fulfillment_orders/3639838146743/fulfillment_request/accept.json";

 

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 219

What happens when you hit this endpoint with a GET request?

/admin/api/2021-01/orders/{order_id}/fulfillments/{fulfillment_id}.json

If you substitute the order ID with a known existing order that is associated with fulfillment, and substitute the fulfillment ID with what you have seen come across that's valid. Do you get the fulfillment in the response?  

0 Likes
Ahsan3
New Member
20 0 0

Just followed your steps for the GET request and it's giving me 

{"fulfillment":null}

 What should be the next step?
I really appreciate your help.

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 219

Hence your 404 error you've been getting. The fulfillment order ID doesn't exist.

Here is an overview that walks you through the steps --> https://shopify.dev/tutorials/manage-fulfillments-with-fulfillment-and-fulfillmentorder-resources. That's a good place to start. There are a lot of steps, and one thing I know is that if you plan on using the API for requesting, accepting, and rejecting fulfillments then the fulfillment service that's registered needs to be registered through the API.

For example, I have a test shop and had an order that was already flagged for manual custom fulfillment. When I tried to hit that in the fulfillment request endpoint the call was rejected with a HTTP 422 status "The fulfillment order's assigned fulfillment service must be of api type."  

0 Likes
Ahsan3
New Member
20 0 0

I had created a fulfillment service through the API and received a successful response. Below was my request code:

$fulfillment = array (
'fulfillment_service' => array (
'name' => 'SS Active Wear',
'handle' => 'ssactivewear',
'callback_url' => 'https://f22a5f120d58.ngrok.io/shopify_test/inventory_check.php',
'inventory_management' => true,
'tracking_support' => true,
'requires_shipping_method' => true,
'format' => 'json',
),
);

 

This was my response:

{
"fulfillment_service": {
"id": 57105186999,
"name": "SS Active Wear",
"email": null,
"service_name": "SS Active Wear",
"handle": "ss-active-wear",
"fulfillment_orders_opt_in": false,
"include_pending_stock": false,
"provider_id": null,
"location_id": 60534456503,
"callback_url": "https://f22a5f120d58.ngrok.io/shopify_test/inventory_check.php",
"tracking_support": true,
"inventory_management": true
}
}

I just notice that "fulfillment_orders_opt_in": false.  Do you think that this is the root cause of the acceptance failures? If so how can I fix it?

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 219
You would presumably need to remove the existing fulfillment service you registered and register it again with the opt in flag set to true. Details here

https://shopify.dev/docs/admin-api/rest/reference/shipping-and-fulfillment/fulfillmentservice

Please throughly read the other reference guide I linked to earlier. It goes over every single step that needs to be followed. All the answers are there if you follow it!
0 Likes
Ahsan3
New Member
20 0 0

Thanks Greg for your help, as instructed here's what I have done now:

  1. I registered a new fulfillment service this time with "fulfillment_orders_opt_in": true and received the confirmation in the response as well.
  2. Assigned a product to my new fulfillment service.
  3. Placed the order and sent the fulfillment request to my app.
  4. Tried sending the acceptance this time but it resulted in 
    422 
    {"errors":{"name":["has already been taken"]}}

  5. I further went down to check the GET fulfillment as guided above by you and that also resulted in the same error 422 {"errors":{"name":["has already been taken"]}}

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 219

I'm wondering if the new fulfillment service you registered has the exact same name as the previous one. Perhaps try deleting the previous one if you haven't already (https://shopify.dev/docs/admin-api/rest/reference/shipping-and-fulfillment/fulfillmentservice#destro...). Also, perhaps try registering a fulfillment service with a unique name. See https://community.shopify.com/c/Shopify-APIs-SDKs/POST-admin-fulfillment-services-json-fails-with-42... for a similar scenario...

0 Likes
Ahsan3
New Member
20 0 0

Hi Greg, This is what I have done:

1. Removed my old Fulfillment
2. Registered a new fulfilment with "fulfillment_orders_opt_in": true,
3. Created a new product with a new service location id
4. Verified the variation inventory managed by in shopify Admin
it shows the name of my new service
5. Created the order and shopify admin shows my fulfillment name on that order
6. I then sent the fulfillment from shopify admin however didn't receive the request notification on my call back URL. Whereas test notification through test webhook fulfillment/create is always received on the same callback URL
7. I then tried this for my order GET /admin/api/2021-01/orders/{order_id}/fulfillments/{fulfillment_id}.json
and that says {"fulfillment":null}


Any help? why the actual order notification is not being received; whereas the test notification is always received.

0 Likes