Quantcast
Viewing all articles
Browse latest Browse all 14069

How to insert shipment tracking code via Rest API Python wrapper and WooCommerce Shipment Tracking plug-in

Set-up

I'm using the official WooCommerce Shipment Tracking plug-in to match orders with tracking codes.

I'm also using Python and the WooCommerce Rest API to do as much as possible via scripts.


Issue

The Shipment Tracking plug-in should work with the REST API, see: https://docs.woocommerce.com/document/shipment-tracking/#section-8.

However, the explanation stated on the documentation page does not contain a Python example.

I'm not sure how to insert the tracking number and tracking provider via Python and the WooCommerce REST API in the WooCommerce back-end.


Code

Using,

data = {'tracking_number': tracking_number,'tracking_provider': tracking_provider,'date_shipped': datetime.datetime.today().strftime('%Y-%m-%d')        }

I have tried,

  • wcapi.post('orders/'+ order_id +'/shipment-trackings', data).json()
  • wcapi.put('orders/'+ order_id +'/shipment-trackings', data).json()
  • wcapi.post('orders/'+ order_id, data).json()
  • wcapi.put('orders/'+ order_id, data).json()

but all yield a 404 error.

What am I doing wrong?


Viewing all articles
Browse latest Browse all 14069

Trending Articles