Below function can be used for generating a return label using fedex API
printReturnLabel: function (data, authorization) {
try {
var url = Configuration.get(‘FedEx.ShipAPIURL’);
var customerTransactionID = Configuration.get(‘FedEx.xcustomertransactionid’);
var xLocale = Configuration.get(‘FedEx.xlocale’);
var bodyObj = data;
var headers = {
‘Authorization’: authorization,
‘x-customer-transaction-id’:customerTransactionID,
‘x-locale’:xLocale,
‘Content-Type’: ‘application/json’,
‘Accept’: ‘*/*’,
‘Accept-Encoding’: ‘gzip, deflate, br’,
‘Connection’: ‘keep-alive’
}
var apiResponse = nlapiRequestURL(url, bodyObj, headers, null, “POST”);
return apiResponse
} catch (err) {
console.error(“error in FedEX printReturnLabel suitescript”, err);
}
}
where
sample data =
{
“labelResponseOptions”: “URL_ONLY”,
“requestedShipment”: {
“shipper”: {
“contact”: {
“personName”: “SHIPPER NAME”,
“phoneNumber”: 1234567890,
“companyName”: “Shipper Company Name”
},
“address”: {
“streetLines”: [
“SHIPPER STREET LINE 1”
],
“city”: “HARRISON”,
“stateOrProvinceCode”: “AR”,
“postalCode”: 72601,
“countryCode”: “US”
}
},
“recipients”: [
{
“contact”: {
“personName”: “NAME”,
“phoneNumber”: 1234567890,
“companyName”: “Recipient Company Name”
},
“address”: {
“streetLines”: [
“RECIPIENT STREET LINE 1”,
“RECIPIENT STREET LINE 2”
],
“city”: “Collierville”,
“stateOrProvinceCode”: “TN”,
“postalCode”: 38017,
“countryCode”: “US”
}
}
],
“shipDatestamp”: “2020-07-03”,
“serviceType”: “PRIORITY_OVERNIGHT”,
“packagingType”: “FEDEX_ENVELOPE”,
“pickupType”: “USE_SCHEDULED_PICKUP”,
“blockInsightVisibility”: false,
“shippingChargesPayment”: {
“paymentType”: “SENDER”
},
“shipmentSpecialServices”: {
“specialServiceTypes”: [
“RETURN_SHIPMENT”
],
“returnShipmentDetail”: {
“returnType”: “PRINT_RETURN_LABEL”
}
},
“labelSpecification”: {
“imageType”: “PDF”,
“labelStockType”: “PAPER_85X11_TOP_HALF_LABEL”
},
“requestedPackageLineItems”: [
{
“weight”: {
“value”: 1,
“units”: “LB”
}
}
]
},
“accountNumber”: {
“value”: “XXX561073”
}
}
authorization = generated token