Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shariff's avatar
Level 50

Internal server error 500 while calling POST API (Laravel)

Hi, I have created one POST API for sending mails. When I am calling this API I am getting an error like this

Http failure response for http://starshipllp.com/starship-backend/public/api/sendEmail: 500 Internal Server Error full detail error

error:
message: "Server Error"
__proto__: Object
headers: Ep
lazyInit: ()=> {…}
arguments: (...)
caller: (...)
length: 0
name: ""
__proto__: ƒ ()
[[FunctionLocation]]: main-es2015.6970d90….js:1
[[Scopes]]: Scopes[4]
lazyUpdate: null
normalizedNames: Map(0) {}
__proto__: Object
message: "Http failure response for http://starshipllp.com/starship-backend/public/api/sendEmail: 500 Internal Server Error"
name: "HttpErrorResponse"
ok: false
status: 500
statusText: "Internal Server Error"
url: "http://starshipllp.com/starship-backend/public/api/sendEmail"

my controller

public function sendMail(Request $request)
     {
         $data = $this->validate($request,[
             'name' => 'required',
             'email' => 'required',
             'phone' => 'required',
             'address' => 'required',
             'orders' => 'required',
             'grandTotal' => 'required'
         ]);

         $emails = [$request->email,'[email protected]'];

         Mail::to($emails)->send(new SendOrderEmail($data));

         return response()->json(['success' => true,'data' => 'Order Placed Successfully']);
     }

I don't know what is wrong in my code.

0 likes
12 replies
Sinnbeck's avatar

Check your log at storage/logs/laravel.log

2 likes
shariff's avatar
Level 50

@sinnbeck thanks for your response. In logs it is not showing anything if I hit the API.

Sinnbeck's avatar

Then the error might be a server error. Check the server log instead (nginx or apache)

shariff's avatar
Level 50

In logs the last error is this.

[2020-10-22 09:45:11] local.ERROR: Invalid route action: []. {"exception":"[object] (UnexpectedValueException(code: 0): Invalid route action: []. at C:\xampp\htdocs\starship\vendor\laravel\framework\src\Illuminate\Routing\RouteAction.php:91)
Sinnbeck's avatar

That is from laravels log I assume? Did you check the web servers?

Is this by any chance shared hosting where this part is a folder backend/public/? That is known to cause issues, if that is the case

jjoek's avatar

From the error, on your api.routes or where you've defined the route, check that the controller action you passing to the route exists in the controller

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Then I am quite certain that this is a server error (the error in your first post even says so). What server are you running on (nginx or apache)? Can you find the log?

shariff's avatar
Level 50

@sinnbeck You are right it was from server error. It is a new cpanel so the .env file was hidden. after changing setting configuration it was working fine.

Thank you very very much for guiding me if u were not telling about server error I should have wasting more time in that. Thank you once again.

Please or to participate in this conversation.