Bulk Update Shopify tracking codes by rest API in Python

JamesH-DS
Visitor
1 0 0

 How can I bulk update the tracking code and courier (tracking company).

I have referred to Create a new fulfillment Shopify dev documentation, but this will only gave me <Response [400]>

And I tried this one Creats a fulfillment for one or many fulfillment orders. After sending the request, I got<Response [201]>, but the order shows in progress instead of fulfilled.

The following are the codes I was using. How can I update the tracking code and company.

 

 

### Python Environment
import pandas as pd  
import numpy as np
from datetime import datetime, timedelta
import requests 
import json
from requests.structures import CaseInsensitiveDict
headers = CaseInsensitiveDict() 

### API Authentication
# add parameter to headers
access_token = f'{token}'
headers["Content-Type"] = "application/json"
headers["X-Shopify-Access-Token"] = f"{access_token}"

 

 

 

data = {}
data['fulfillment'] = {}
data['fulfillment']['tracking_info'] = {}
data['fulfillment']['location_id'] = f'{location_id}'  # location id
data['fulfillment']['notify_customer'] = False
data['fulfillment']['status'] = 'success'
data['fulfillment']['tracking_info']['number'] = f'{trackingCode}'
data['fulfillment']['tracking_info']['company'] = 'DHL Express'
data['fulfillment']['tracking_info']['tracking_urls'] = f'https://www.dhl.com/us-en/home/tracking/tracking-express.html?submit=1&tracking-id={trackingCode}'

 

 

 

### Send the post request to update the tracking code
createFulfillment_url = f'{shop_url}/admin/api/2022-04/orders/{orderID}/fulfillments.json'
request.post(createFulfillment_url, headers = headers, json = data )

 

After sending the request, I got Response [201], but the order shows in progress instead of fulfilled. Also the tracking code and the tracking company don't appear in the shop.

 

Replies 0 (0)