Shopify api fulfillment or order.save() not working in python

Shopify api fulfillment or order.save() not working in python

Romain_97
Visitor
1 0 1

Hello, I am trying to create a fulfillment for shopify orders that doesn't have fullfilment yet.

I have tried with fulfillment.save() by creating a shopify.Fulfillment object, also with fulfillment.create() and also with order.save() after adding the fulfillment object to the order.fulfillments list but nothing works.

 

Here is a part of my code in python : 

 

fulfillment = shopify.Fulfillment({
'order_id': order.id,
'location_id': 71647264989,
'line_items': order.line_items

})
fulfillment.tracking_company = 'Colissimo'
fulfillment.tracking_number = f'{num_suivi}'
fulfillment.tracking_url = 'https://www.laposte.fr/outils/suivre-vos-envois'
fulfillment.notify_customer = True
fulfillment.save()

 

 

 

and here is the error message I get : 

ResourceNotFound: Not Found: https://'myshop'.myshopify.com/admin/api/2023-01/orders/5067045699805/fulfillments.json

 

Actually I don't understand where the problem comes from, I also updated my API autorisation for the token I am using and I selected all autorisations so it should be okay.

 

if I try to access the link from the error message, I see the fulfillments list which is empty.

 

If one of you have any idea to solve this problem it would be great.

Reply 1 (1)

ShopifyDevSup
Shopify Staff
1453 238 508

Hey @Romain_97,

I took a closer look at your post, and wanted to pass on a few things.  

  • First, there is an extensive Fulfillment Apps overview doc to help determine which workflow(s) and APIs an app will need, scopes required, and other insights specific to any processes.
  • This guide on migrating to fulfillment orders also includes details around important changes to handling fulfillments via the API.

After reviewing those resources and confirming that the app has all necessary scopes, I'd take another look at the input data.

Using the fulfillment resource endpoint POST /orders/{order_id}/fulfillments.json and the current API version 2023-01, be sure to reference the API docs to confirm all required fields for creating a fulfillment on a fulfillment order.

Here is an example payload with required fields from recent changes highlighted:

 

POST .../admin/api/2023-01/fulfillments.json

{
  "fulfillment":{
    "message":"{EXAMPLE MESSAGE}",
    "notify_customer":false,
    "tracking_info":{
      "number":{
        SOME_TRACKING_NUMBER
      },
      "url":"{EXAMPLE_URL}",
      "company":"{EXAMPLE_COMPANY_NAME}"
    },
    "line_items_by_fulfillment_order":[
      {
        "fulfillment_order_id":{
          {
            fulfillment_order_id
          }
        },
        "fulfillment_order_line_items":[
          {
            "id":{
              {
                fulfillment_order.line_item.id
              }
            },
            "quantity":{
              SOME_QUANTITY
            }
          }
        ]
      }
    ]
  }
}

 


It is worth noting that while we aren't currently able to share any example code or in this case python specific examples, the error message appears to be related to either the input or potentially a lack of necessary API scopes. 

As a closing note, consider using an API client (Postman, Insomnia) to help debug and inform structure for any API calls, this can be invaluable for testing purposes. Hope that helps get the error sorted out on your end! 

Cheers,
@awwdam - Shopify Developer Support

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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