skip to Main Content

I am trying to interact with AlienTech API using IlluminateSupportFacadesHttp; 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?

2

Answers


  1. 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.

    Login or Signup to reply.
  2. If you are on a local server, than if you turn on the debug option you are able to see the specific error with details in the laravel.log file. https://laravel.com/docs/10.x/errors

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search