post https://api.easyship.com/label//labels
attribute | type | description |
---|---|---|
easyship_shipment_id | string | Easyship Shipment ID provided when creating the shipment |
courier_id | string | Courier ID in case you need to overwrite the one suggested by default, example: b4552ed2-ae95-4647-9746-5790bf252c7f |
##Request
curl --include \
--request POST \
--header "Content-Type: application/json" \
--header "Authorization: Bearer 4e2b327e2ef5471885cd0bc50a0c9fe52481793bd309b2c4f2a6bdac3f10ae1f" \
--data-binary "{
\"shipments\": [
{
\"easyship_shipment_id\": \"ESUS3171766\",
\"courier_id\": \"b4552ed2-ae95-4647-9746-5790bf252c7f\"
},
{
\"easyship_shipment_id\": \"ESUS2513756\"
}
]
}" \
'https://api.easyship.com/label/v1/labels'
var request = require('request');
request({
method: 'POST',
url: 'https://api.easyship.com/label/v1/labels',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer 4e2b327e2ef5471885cd0bc50a0c9fe52481793bd309b2c4f2a6bdac3f10ae1f'
},
body: "{ \"shipments\": [ { \"easyship_shipment_id\": \"ESUS3171766\", \"courier_id\": \"b4552ed2-ae95-4647-9746-5790bf252c7f\" }, { \"easyship_shipment_id\": \"ESUS2513756\" } ]}"
}, function (error, response, body) {
console.log('Status:', response.statusCode);
console.log('Headers:', JSON.stringify(response.headers));
console.log('Response:', body);
});
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'
values = '{
"shipments": [
{
"easyship_shipment_id": "ESUS3171766",
"courier_id": "b4552ed2-ae95-4647-9746-5790bf252c7f"
},
{
"easyship_shipment_id": "ESUS2513756"
}
]
}'
headers = {
:content_type => 'application/json',
:authorization => 'Bearer 4e2b327e2ef5471885cd0bc50a0c9fe52481793bd309b2c4f2a6bdac3f10ae1f'
}
response = RestClient.post 'https://api.easyship.com/label/v1/labels', values, headers
puts response
from urllib2 import Request, urlopen
values = """
{
"shipments": [
{
"easyship_shipment_id": "ESUS3171766",
"courier_id": "b4552ed2-ae95-4647-9746-5790bf252c7f"
},
{
"easyship_shipment_id": "ESUS2513756"
}
]
}
"""
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer 4e2b327e2ef5471885cd0bc50a0c9fe52481793bd309b2c4f2a6bdac3f10ae1f'
}
request = Request('https://api.easyship.com/label/v1/labels', data=values, headers=headers)
response_body = urlopen(request).read()
print response_body
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.easyship.com/label/v1/labels");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{
\"shipments\": [
{
\"easyship_shipment_id\": \"ESUS3171766\",
\"courier_id\": \"b4552ed2-ae95-4647-9746-5790bf252c7f\"
},
{
\"easyship_shipment_id\": \"ESUS2513756\"
}
]
}");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Authorization: Bearer 4e2b327e2ef5471885cd0bc50a0c9fe52481793bd309b2c4f2a6bdac3f10ae1f"
));
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
var request = new XMLHttpRequest();
request.open('POST', 'https://api.easyship.com/label/v1/labels');
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Authorization', 'Bearer 4e2b327e2ef5471885cd0bc50a0c9fe52481793bd309b2c4f2a6bdac3f10ae1f');
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};
var body = {
'shipments': [
{
'easyship_shipment_id': 'ESUS3171766',
'courier_id': 'b4552ed2-ae95-4647-9746-5790bf252c7f'
},
{
'easyship_shipment_id': 'ESUS2513756'
}
]
};
request.send(JSON.stringify(body));
##Response
{
"message": "Your labels are being generated",
"errors": [],
"total_cost": 76,
"available_balance": 924,
"labels": [
{
"easyship_shipment_id": "ESUS3171766",
"label_state": "pending",
"label_url": null,
"status": "success",
"tracking_number": null,
"tracking_page_url": "https://www.easyship.com/shipment-tracking/ESUS3171766"
},
{
"easyship_shipment_id": "ESUS2513756",
"label_state": "pending",
"label_url": null,
"status": "success",
"tracking_number": null,
"tracking_page_url": "https://www.easyship.com/shipment-tracking/ESUS2513756"
}
]
}