Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: 406 error when creating Fulfillment for FulfillmentOrder with Python SDK

406 error when creating Fulfillment for FulfillmentOrder with Python SDK

travisd
Shopify Partner
7 0 5

Hi there, 

 

Can someone at Shopify help me with with this issue?

X-Shopify-API-Version: 2021-10

X-Request-IDs: 14002aab-1fdc-437b-969f-175bf15721bb, 5a237171-bf5f-4552-9391-45b0bdc5d6c6

I have a FulfillmentOrder, and am attempting to create a Fulfillment based on that FO. I'm referencing the documentation here. My app is registered as a fulfillment service, and I believe has the appropriate API scopes: read/write merchant_managed_fulfillment_orders, read/write fulfillments).

 

The code:

 

 

 

fo = shopify.FulfillmentOrders.find(order_id="4542337646746")[0]
fulfillment = shopify.Fulfillment()
fulfillment.message = "The package was shipped this morning."
fulfillment.notify_customer = False
fulfillment.tracking_info = {
  "number": "1562678",
  "url": "https://www.my-shipping-company.com",
  "company": "my-shipping-company"
};
fulfillment.line_items_by_fulfillment_order = [
  {
    "fulfillment_order_id": fo.id,
    "fulfillment_order_line_items": [
      {
        "id": fo.line_items[0].id,
        "quantity": 1
      }
    ]
  }
]

fulfillment.save()

 

 

 

The error:

 

urllib.error.HTTPError: HTTP Error 406: Not Acceptable

 

Thanks in advance!

Travis

 

 

Replies 4 (4)

JamesG
Shopify Staff
42 10 11

Hey @travisd 

I checked our logs for the request ID you shared and found a POST to the following endpoint, which has an invalid format:

/admin/api/2021-10/orders//fulfillments.json


You may just need to check how you are formatting your requests, but troubleshooting third party code is outside of my team's scope of support. 

 

  •  If you continue to have issues using the Shopify API I would recommend testing the API calls in an HTTP client like Postman as well to see if you are getting the same result there, and sharing raw examples of your requests along with your code here for the community to help.

 

In case you haven't seen it already, I also wanted to recommend checking out our guide on migrating to the FulfillmentOrder resource, as the Fulfillment resource will be deprecated.

 

Cheers,

JamesG | API 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

travisd
Shopify Partner
7 0 5

Hi @JamesG !

 

Thanks for letting me know about the invalid format on the URL. 

 

Regarding the transition to FulfillmentOrders, how does one provide tracking information for an order without creating a Fulfillment resource? The migration guide and FulfillmentOrder documentation doesn't reference anything about carriers or tracking numbers.  

 

How does one mark the order as "fulfilled" with a FulfillmentOrder? I've read the documentation thoroughly, and I don't see any reference to this. 

 

Thanks!

Travis

 

travisd
Shopify Partner
7 0 5

@JamesG Is there a REST API equivalent of the fulfillmentCreateV2 mutation? 

JamesG
Shopify Staff
42 10 11

Hi @travisd ,

I see you already found the information on the fulfillmentCreateV2 mutation. The Fulfillment.TrackingInfo can be provided as part of the FulfillmentCreateV2Payload when using GraphQL.

I also did some digging into the REST admin API and found out that although several of the features of the Fulfillments resource have been deprecated, it's still necessary to use it to create a new fulfillment in REST, or update tracking information.  

 

  • I see there was a similar post here about this issue too.

 

Apologies for any confusion caused by my last reply, I'll follow up with the documentation team as well to see if we can update the language too. 

 

Cheers,

JamesG | API 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