laravelapirest

Laravel - server error 500 and no way to print error


I am trying to interact with AlienTech API using Illuminate\Support\Facades\Http; in Laravel.

$apiURL = 'https://encodingapi.alientech.to/api/kess3/decode-read-file/user1?callbackURL=https://backend.ecutech.gr/callback/kess3';

        $postInput = [
            'readFile' => public_path('obd1'),
        ];
  
        $headers = [
            'Content-Type' => 'multipart/form-data',
            'X-Alientech-ReCodAPI-LLC' => $token,
        ];
  
        $response = Http::withHeaders($headers)->post($apiURL, $postInput);

        $statusCode = $response->status();
        $responseBody = json_decode($response->getBody(), true);

        dd($responseBody);

$responseBody variable is NULL. Error code is 500. How can I see what I am doing wrong. Is there any way to check logs or errors?


Solution

  • Laravel's HTTP client does not throw exceptions. Try to add

    $response->throw();
    

    after making the request.

    You can find many other options to handle errors in the documentation.