Fulfillment API returning 404

Solved
tsornin
Tourist
6 0 3

I'm trying to post to the Fulfillment (REST) API to fulfill line items on an order. I'm following the instructions from https://shopify.dev/docs/admin-api/rest/reference/shipping-and-fulfillment/fulfillment#create-2020-0..., and POSTing this:

"fulfillment" : {
      "tracking_number" : "",
      "line_items" : [
         {
            "id" : 5073200218215
         }
      ],
      "location_id" : 319520779
   }

to the url https://username:password@shopid.myshopify.com/admin/api/2020-04/orders/2259886243943/fulfillments.json

(with my shop's specific details)

However I'm getting a 404 back from the API, which is really unhelpful.

I've tried it with tracking_number: null, and also with no tracking number at all, but it's always the same: 404.

What now?

I have confirmed that it's the correct location id, order id and line_item id's. The line item is a product whose "requires_shipping" is false. Does that affect this?

 

0 Likes
tsornin
Tourist
6 0 3

More info: 'x-request-id': [ 'eb28f5fb-fb97-407a-9bfa-b0c7e004d1f2' ]

 

0 Likes
Greg_Kujawa
Shopify Partner
965 80 204

If that's the entirety of your JSON request body, aren't you missing the enclosing braces around the entire thing? Like this...

 

{
"fulfillment": {
  "location_id": 203128,
  "tracking_number": "123456789",
  "tracking_numbers": ["123456789"],
  "service": "manual",
  "tracking_url": "https://shipping.xyz/track.php?num=123456789",
  "tracking_urls": ["https://shipping.xyz/track.php?num=123456789"],
  "tracking_company": "Jack Black's Pack, Stack and Track",  
  "receipt": {},
  "line_items": [{"id": 4204529844276, "quantity": 1, "variant_id": null, "fulfillment_service":"manual" }],
  "notify_customer": false
  }
}
0 Likes
vix
Shopify Staff
Shopify Staff
534 105 103

This is an accepted solution.

Hey @tsornin 

Thanks for the information. With any 404 you would be seeing a "not found" error - which to me means one of your IDs is incorrect. Can you confirm that the Order ID, Line Item ID and the Location ID (that corresponds to this line item specifically) are infact the correct ones? 

Let me know

Vix | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

tsornin
Tourist
6 0 3

Solved it - it was in fact using the wrong order ID. I had set a variable earlier in the code for the order ID and was not updating it correctly. (sigh!) 

Thanks!

 

Ahsan3
New Member
18 0 0

Hi, I am trying to send the fulfillment acceptance for a fulfillment order using the fulfillment acceptance API https://shopify.dev/docs/admin-api/rest/reference/shipping-and-fulfillment/fulfillmentrequest#create...  

POST /admin/api/2020-04/fulfillment_orders/1046000825/fulfillment_request/accept.json

But it gives me 404 

{"errors":"Not Found"}

I have made sure 100 times that I am using the correct fulfillment order id and also made sure that this product is assigned to my fulfillment service app. 

Below is my POST request code, can someone please help me to figure out what am I missing here or what is wrong here:

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

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

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $SHOPIFY_API);
$headers = array(
"Authorization: Basic ".base64_encode("$API_KEY:$PASSWORD"),
"Content-Type: application/json",
"charset: utf-8"
);

curl_setopt($curl, CURLOPT_HTTPHEADER,$headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_VERBOSE, 0);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($fulfillment_request));
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);

echo "\n\n";
$response = curl_exec ($curl);
curl_close ($curl);

For Shopify Staff: 
My x-request-id

x-request-id: d7760696-25f6-4b3a-a176-28e0628e5fea

My Shop URL: ss-activewear-new.myshopify.com

 

0 Likes
Greg_Kujawa
Shopify Partner
965 80 204

@Ahsan3 wrote:

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

 


Check the $SHOPIFY_API variable declaration. As there appears to be two forward slashes after $SHOP_URL. Should just be one forward slash, right?

0 Likes
Ahsan3
New Member
18 0 0

That double slash worked perfectly fine for all other APIs like POST product API and Inventory level API. So this is not the issue I guess.  

Can you confirm the payload of the acceptance that I am using? Does it require any other parameter like specifying location Id? or anything else

Please Help!

0 Likes
Greg_Kujawa
Shopify Partner
965 80 204

Don't you have to create a fulfillment order first, and then reference that fulfillment order ID in what you are trying to request?

 

https://shopify.dev/docs/admin-api/rest/reference/shipping-and-fulfillment/fulfillment#create-2021-0...

 

0 Likes
Ahsan3
New Member
18 0 0

When I sent the fulfillment request manually from the store to my app, didn't it create a fulfillment order already? because my app receives it as a fulfillment request notification on my callback URL. So technically an order has already been created and now I have to either accept it or reject it. Or am I missing anything here? Do I still need to create another fulfillment order? 

As per my understanding here is the life cycle of a fulfillment order.

1- The custom app receives the fulfillment request from Shopify.

2- The custom app reads the request and either accepts it or rejects it.

3- If accepted, then we will later send the tracking information as 3rd step.

4- Once the tracking number is posted we will send the fulfillment complete request.

Please let me know if I am missing any process here or is there something wrong with my acceptance request code?

0 Likes