These docs are for v1.0. Click to read the latest docs for v2024.09.

Discussions

Ask a Question
Back to All

I am unable to request /api/rates endpoints

app.get('/api/rates', (request, response) => {
response.setHeader("Access-Control-Allow-Origin", "*");
response.header(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept"
);

const options = {
method: 'POST',
url: 'https://api.easyship.com/2023-01/rates',
headers: {
accept: 'application/json',
'content-type': 'application/json',
authorization: ''
},
data: {
origin_address: {
line_1: 'Kennedy Town',
line_2: 'Block 3',
state: 'Yuen Long',
city: 'Hong Kong',
postal_code: '0000',
country_alpha2: 'HK',
contact_name: 'Foo Bar',
company_name: null,
contact_phone: null,
contact_email: '[email protected]'
},
destination_address: {
country_alpha2: 'HK',
line_1: 'Kennedy Town',
line_2: 'Block 3',
state: 'Yuen Long',
city: 'Hong Kong',
postal_code: '0000',
contact_name: 'Foo Bar',
company_name: null,
contact_phone: null,
contact_email: '[email protected]'
},
incoterms: 'DDU',
insurance: {is_insured: false},
courier_selection: {show_courier_logo_url: true, apply_shipping_rules: true},
shipping_settings: {units: {weight: 'kg', dimensions: 'cm'}, custom_markup_rate: 0.1},
parcels: [
{
box: null,
items: [
{
quantity: 2,
dimensions: {length: 1, width: 2, height: 3},
description: 'item',
category: 'fashion',
sku: 'sku',
origin_country_alpha2: 'HK',
actual_weight: 10,
declared_currency: 'USD',
declared_customs_value: 20
}
],
total_actual_weight: 1
}
]
}
};

axios
.request(options)
.then(function (response) {
response.send(response.data);
})
.catch(function (error) {
response.send(error);
});
})

The response that I am getting:

{"message":"Request failed with status code 403","name":"AxiosError","stack":"AxiosError: Request failed with status code 403\n at settle (\axios.cjs:1970:12)\n at BrotliDecompress.handleStreamEnd (C:\Users\BlackHat\Documents\WebProjects\github\projects\Vamoby\backend\node_modules\axios\dist\node\axios.cjs:3069:11)\n at BrotliDecompress.emit (node:events:526:35)\n at endReadableNT (node:internal/streams/readable:1359:12)\n at process.processTicksAndRejections (node:internal/process/task_queues:82:21)","config":{"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"adapter":["xhr","http"],"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"env":{},"headers":{"Accept":"application/json","Content-Type":"application/json","authorization":"Bearer sand_93QscCPXsq/1mrqXt+erJeefUoKTuwD1DDIT7h5o7BM=","User-Agent":"axios/1.6.5","Content-Length":"982","Accept-Encoding":"gzip, compress, deflate, br"},"method":"post","url":"https://api.easyship.com/2023-01/rates","data":"{\"origin_address\":{\"line_1\":\"Kennedy Town","line_2":"Block 3","state":"Yuen Long","city":"Hong Kong","postal_code":"0000","country_alpha2":"HK","contact_name":"Foo Bar","company_name":null,"contact_phone":null,"contact_email":"[email protected]"},"destination_address":{"country_alpha2":"HK","line_1":"Kennedy Town","line_2":"Block 3","state":"Yuen Long","city":"Hong Kong","postal_code":"0000","contact_name":"Foo Bar","company_name":null,"contact_phone":null,"contact_email":"[email protected]"},"incoterms":"DDU","insurance":{"is_insured":false},"courier_selection":{"show_courier_logo_url":true,"apply_shipping_rules":true},"shipping_settings":{"units":{"weight":"kg","dimensions":"cm"},"custom_markup_rate":0.1},"parcels":[{"box":null,"items":[{"quantity":2,"dimensions":{"length":1,"width":2,"height":3},"description":"item","category":"fashion","sku":"sku","origin_country_alpha2":"HK","actual_weight":10,"declared_currency":"USD","declared_customs_value":20}],"total_actual_weight":1}]}"},"code":"ERR_BAD_REQUEST","status":403}


The error Request failed with status code 403 (not authorized!!!)

{
"error": {
"code": "forbidden",
"details": [
"Access to this resource requires scope(s) rate, custom_markup_rate."
],
"message": "You do not have permission to access this resource. Please contact our support team or your account manager if you believe you should have access.",
"request_id": "70e7fd2c1e8646ad5f873fe858cb133c",
"type": "invalid_request_error"
}
}