I'm in Laravel 5.8 in Windows trying to create an inbound API route. Postman always gives me a 404 when I try to hit this route:
http://MYHOSTISHERE/api/v1?event=NewDealerSetUp&api_key=MYKEYISHERE
CURL with
curl -X POST "http://rx-0-unicorn.local/api/v1?event=NewDealerSetUp&api_key=MYAPIKEYHERE"
also gives me a 404.
Can someone point me to what I'm doing wrong? I'm bald but I may start pulling out beard in a minute.
Details below, and thanks!
I have this route in app.php:
Route::post('v1?event={event}&api_key={api_key}', 'API\APIController@index');
The route shows in artisan route list:
| | POST | api/v1?event={event}&api_key={api_key} | | App\Http\Controllers\API\APIController@index | api |
VerifyCsrfToken Middleware (just to see if it would work):
protected $except = [
'api/*'
];
Controller start:
namespace App\Http\Controllers\API;
use App\Models\Log\LogAPI;
use App\Models\Members;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redirect;
class APIController extends Controller
{
public function index($event, $api_key, Request $request)
{
$data = filter_var_array((array)$request, FILTER_SANITIZE_SPECIAL_CHARS);
[...]
if($event == 'NewDealerSetUp'){
$setup = new NewDealerSetup();
return $setup->newDealerSetup($request);
}
.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# ------------------------------------------------------------------------------------------------------
# NOTES:
# the log: strip per-dir prefix: C:/apache/htdocs/MYAPPNAME/public/ ->[EMPTY] ... takes the ^[EMPTY] and returns an empty
# ------------------------------------------------------------------------------------------------------
</IfModule>