Error 406 when making a POST fulfillment request

luizhenrique
Shopify Partner
5 1 0

I'm making a request to the endpoint:

 

 

https://###.myshopify.com/admin/api/2021-10/orders/{{order.legacyResourceId}}/fulfillments.json

 

 

with the body:

 

{
 "fulfillment":{
     "location_id":65503887518,
     "tracking_number":"CLICKHERE",
     "tracking_urls":[
       "{{order.note | replace: 'Cód. de Rastreamento:',''}}"
      ],
      "notify_customer":true
  }
}

 

 

In Postman everything works perfectly, but in the flow I get the following error:

 

 

{"status":406,"response_body":"","verb":"POST","url":"https://###.myshopify.com/admin/api/2021-10/orders/4530109270171/fulfillments.json","request_body":"{\"fulfillment\":{\"location_id\":65503887518,\"tracking_number\":\"CLICKHERE\",\"tracking_urls\":[\" http://tracking.totalexpress.com.br/poupup_track.php?reid=###&pedido=#####&nfiscal=0\n\"],\"notify_customer\":true}}"}

 

 

The request is exactly the same. Same headers, same body. The only difference is the dynamic values.

Important note. When I create a manual order and run the flow. Everything works, but when I run the flow in a real product this error happens.

Replies 4 (4)

paul_n
Shopify Staff
930 127 223

Does your note include characters that might cause issues with json? I’d recommend adding the tag “| json” any time you are trying to output json to make sure it’s escaped. 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
luizhenrique
Shopify Partner
5 1 0

I checked, it doesn't include, even so I added the “| json”, I keep getting the same error. As I mentioned, when I create a manual order and run the flow everything works. When it's a real order, the flow follows the same flow and I get a 406 on the request.

paul_n
Shopify Staff
930 127 223

Assuming it's not that field, the server is not liking something. 

 

I would review this:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406

 

It suggests that you may not be setting the same headers that are sent via postman. Try sending your request to a URL where you can inspect the output (ngrok or something like https://hookbin.com/)  and then compare the headers and inspect the body of the request with the dynamic data.

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
paul_n
Shopify Staff
930 127 223

A second thing to check:

https://###.myshopify.com/admin/api/2021-10/orders/{{order.legacyResourceId}}/fulfillments.json

Are you sure this URL is valid? I'm not sure what action you are trying to do, but I couldn't find any POST in the Shopify REST API that has this URL format...there is a GET request here but that would not work with Flow and your body doesn't match.

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.