Discussions

Ask a Question
Back to All

Validation Failure Error in API response

Hello Easyship team,

I am using your API in my website in curl format, so i have used the following code:

---------------------------------------------code starts here ------------------------------------------
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://api.easyship.com/rate/v1/rates");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);

curl_setopt($ch, CURLOPT_POST, TRUE);

curl_setopt($ch, CURLOPT_POSTFIELDS, "{
"origin_country_alpha2": "SG",
"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
}
]
}");

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Authorization: Bearer 4e2b327e2ef5471885cd0bc50a0c9fe52481793bd309b2c4f2a6bdac3f10ae1f"
));

$response = curl_exec($ch);
curl_close($ch);

var_dump($response);
-------------------------------------------------- code ends here ----------------------------------------
but it is giving me the following response :

"string(146) "{"rates":[],"messages":["Validation Failure: No credentials","Sorry, we couldn't find any shipping solutions based on the information provided."]}""

Please provide me a solution so that i can use it.

thanks