Discussions

Ask a Question
Back to All

unable to generate shipping label

I'm trying to create a shipment by combining create shipment and buying a label by following your this API docs "https://developers.easyship.com/reference#create-a-shipment".I was able to create a shipment , but no label was generated..

values = {
"platform_name": "Cura Health ",
"platform_order_number": "001",
"destination_country_alpha2": order.destination_country,
"destination_city": order.destination_city,
"destination_postal_code": order.destination_postal_code,
"destination_state": order.destination_state,
"destination_name": order.name,
"destination_company_name": "Hugo",
"destination_address_line_1": order.address,
"destination_address_line_2": order.address2,
"destination_phone_number": order.phone,
"destination_email_address": order.email_address,
"items": [
{
"description": "Silk dress",
"actual_weight": 0.5,
"height": 10,
"width": 15,
"length": 20,
"category": "fashion",
"declared_currency": "SGD",
"declared_customs_value": 100
}
],

                    "shipments": [
                    {
                    "easyship_shipment_id": order.shipment_id,
                    "courier_id": ""
                    },
                    ]
                  }



            headers = {
            'Content-Type': 'application/json',
            'Authorization': 'Bearer xxxxxProduction API xxxxxx'
            }
            r = requests.post("https://api.easyship.com/shipment/v1/shipments/create_and_buy_label", data=json.dumps(values), headers=headers)
            print(r.json())
            order.shipment_id = r.json()['shipment']['easyship_shipment_id']
            order.shipment_status = 'Created'
            print(r.text)