Need help for shipcloud api php laravel

I try to use api from https://developers.shipcloud.io but it show unauthorized. It’s not working post request by php laravel. Here is my code:


$datas = array(           "to" => array(               "company" => "Receiver Inc.",               "first_name" => "John",               "last_name" => "Doe",               "street" => "Beispielstrasse",               "street_no" => "42",               "city" => "Musterhausen",               "zip_code" => "22100",               "country" => "DE"           ),           "package" => array(               "weight" => 15,               "length" => 30,               "width" => 30,               "height" => 30,               "type" => "parcel"           ),           "carrier" => "dpd",           "service" => "standard",           "reference_number" => "84ff5818cec11271a7c42f498ef7536d",           "notification_email" => "[email protected]",           "create_shipping_label" => true         );         $client = new \GuzzleHttp\Client();        $dt =  json_encode($datas);         $response = Http::post('https://api.shipcloud.io/v1/shipments',              [                    'auth' => array('bk_sandbox_apikey' => ''),                  'data' => $dt,             ]); 

Add Comment
1 Answer(s)

You are probably getting a 401 status code because you are not passing any authentication data.

[     'auth' => ['bk_sandbox_apikey' => ''],     'data' => $dt, ] 

you should add your API key in bk_sandbox_apikey

You can read more about the error you are getting here

Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.