Discussions

Ask a Question
Back to All

Cannot request a rate

Hi all. I am having trouble trying to request a rate.

I have tried 2 different methods to no avail. The first I get a 500 error "We're sorry, but something went wrong (500)" while the second I keep getting a "{"message":"Rates could not be calculated","errors":["No Items"]}" error. Both are attempted using JS.

1st method...
$.ajaxSetup({
headers: {
Authorization: "Bearer prod_myKEY"
},
data: {
origin_postal_code: "92630",
destination_country_alpha2: "US",
destination_postal_code: "10001",
taxes_duties_paid_by: "Sender",
is_insured: false,
items: [
{
actual_weight: 1.2,
height: 10,
width: 10,
length: 10,
category: "fashion",
declared_currency: "USD",
declared_customs_value: 100
}
]
}
});
$.post('https://api.easyship.com/rate/v1/rates',
function(data) {
console.log(data);
});

2nd method...

$.ajaxSetup({
headers: {
Authorization: "Bearer prod_myKEY"
},
data: JSON.stringify('{"origin_postal_code":"WC2N","destination_country_alpha2":"US","destination_postal_code":"10030","taxes_duties_paid_by":"Sender","is_insured":false,"items":[{"actual_weight":1.2,"height":10,"width":15,"length":20,"category":"mobiles","declared_currency":"SGD","declared_customs_value":100}]}')
});
$.post('https://api.easyship.com/rate/v1/rates',
function(data) {
console.log(data);
});

What I am doing wrong???