I'm in Laravel 5.8 in Windows trying to create an inbound API route (which I've never done before - we have hundreds of routes that all work just fine, but this one seems to be killing us). Postman always gives me a 404 when I try to hit this route. It never seems to match the route at all.
Am I doing something wrong in either Postman or my setup?
Please help before I pull out my beard!
http://MYHOSTISHERE/api/v1?event=NewDealerSetUp&api_key=MYKEYISHERE
I have this route:
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 |
I've set all api routes unprotected in VerifyCsrfToken middleware:
protected $except = [
'api/*'
];
The start and end of my controller:
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);
}
And here is my .htaccess file:
<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>