Level 122
Why are you using POST routes for what are essentially GET functions?
Have a look in the Laravel error logs to see the cause of the 500 error.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
These are my routes:
Route::post('get_client', 'API\ClientController@ShowClient');
Route::post('new_loans', 'API\LoanController@ShowNewLoans');
Route::post('new_loans/{BR_ID}', 'API\LoanController@ShowNewLoans');
get_client, but works locally on my personal computer:
public function ShowClient(Request $request) {
return response()->json(['message' => 'Okay'], 200);
}
Below works perfectly locally and on the server:
public function ShowNewLoans($BR_ID = null) {
if ($BR_ID == null) {
$newLoans = Loans::where([
['APPLICATION_NO', NULL],
['OL_TEMP_APP_NO', '!=', NULL],
['ActivityListID', '!=', 5]
])->get();
} else {
$newLoans = Loans::where([
['APPLICATION_NO', NULL],
['OL_TEMP_APP_NO', '!=', NULL],
['ActivityListID', '!=', 5],
['BR_ID', $BR_ID]
])->get();
}
if ($newLoans->isEmpty()) {
return response()->json(["message" => "There are no online new loan applications found."], 204);
} else {
return response()->json($newLoans, 200);
}
}
What am I missing here? They both use the same namespace. The codes work perfectly in my computer but when its on my hosting server (Amazon EC2) it returns an error 500. These are the headers from postman:
Date
Thu, 21 May 2020 08:16:22 GMT
Server
Apache/2.4.41 (Amazon) OpenSSL/1.0.2k-fips PHP/7.3.15
X-Powered-By
PHP/7.3.15
Cache-Control
no-cache, private
Content-Length
1750
Connection
close
Content-Type
text/html; charset=UTF-8
Please or to participate in this conversation.