We are building an app in Django to fulfill orders. We are able to fulfill orders by HTTP request but are unable to do the same with the python ShopifyAPI library. Below is the code.
shopify.Session.setup(
api_key=settings.SHOPIFY_API_KEY, secret=settings.SHOPIFY_API_SECRET)
api_version = settings.SHOPIFY_API_VERSION
shop_url = settings.SHOPIFY_SELLER_URL.replace(
"storeName", store['referenceName'])
session = shopify.Session(shop_url, api_version, store['token'])
shopify.ShopifyResource.activate_session(session)
locationId = body.get('locationId')
trackingCode = body.get('trackingNumber')
carrierCompany = body.get('carrierCompany')
trackingURL = body.get('trackingURL')
fulfillment = {}
fulfillment['tracking_info'] = {}
fulfillment['line_items_by_fulfillment_order'] = []
fulfillment['location_id'] = f'{locationId}' # location id
fulfillment['notify_customer'] = False
fulfillment['status'] = 'success'
fulfillment['tracking_info']['number'] = f'{trackingCode}'
fulfillment['tracking_info']['company'] = f'{carrierCompany}'
fulfillment['tracking_info']['tracking_urls'] = f'{trackingURL}'
fulfillment['line_items_by_fulfillment_order'].append({'fulfillment_order_id': orderId})
fulfillments = shopify.Fulfillment.create(fulfillment, order_id = orderId)
Any help would be greatly appreciated!