rommeltraya25's avatar

Laravel 9 POST Route Appears as GET Instead of POST

I'm encountering an issue in Laravel 9 where I have defined a route with the POST method, like so: //Route Route::post('receive-waiver', ReceiveWaiverController::class);

However, when I tested this route, I noticed that in the developer tools network tab, the request appears as a GET method instead of a POST. Consequently, I receive an error message stating: "The GET method is not supported for route 'receive-waiver'. Supported methods: POST."

The request must be accessing the URL only for the purpose of this URL for webhook. The webhook sender is from another app and I don't have control of their codes.

I'm perplexed by this behavior, as I've clearly defined the route as a POST route. Can anyone help me understand why this is happening and provide guidance on how to resolve it? I want to ensure that my 'receive-waiver' route is accessed using the correct HTTP method, which should be POST. Thank you in advance for your assistance!

PS: Before testing, I run these commands:

composer dump-autoload, chown -R www-data:www-data ., chmod -R 775 ., #php artisan migrate, php artisan config:cache, php artisan route:cache, php artisan route:clear, php artisan cache:clear, php artisan view:clear, php artisan optimize, php artisan queue:restart,

0 likes
19 replies
jaseofspades88's avatar

If the route is defined as a POST, it is not possible for it to appear as a GET. Check your route definition and use php artisan route:list to check the defined routes. No need to mess about with permissions as this won't affect your routes.

1 like
rommeltraya25's avatar

@jaseofspades88 In my php artisan route:list, my route is in post. POST domain.local/receive-waiver ................. yet the error persists

vincent15000's avatar

Please show all routes with receive-waiver.

php artisan route:list | grep 'receive-waiver'
rommeltraya25's avatar

@vincent15000 POST {subdomain}.gymdesk.local/receive-waiver .......................................................................................................................................... Zoho\ReceiveWaiverController

1 like
rommeltraya25's avatar

@vincent15000 I only want the URL of this route. I will be using this as a callback URL Webhook in another app which I do not have control. The webhook sender only wants callback URL.

1 like
vincent15000's avatar

@rommeltraya25 Then you need to check which method (GET, POST, ...) is used by the Zoho request.

According to what you have already showed us, it's a GET request, so you should declare the route as a GET route.

rommeltraya25's avatar

@vincent15000 I did try the GET method, but the data from ZOHO cannot be passed. I also did try logs "\Log::info('Data:' . $request);" and the $request only shows the header of the Zoho, not the data. This requires the POST Method.

1 like
rommeltraya25's avatar

@vincent15000 help.zoho.com/portal/en/community/topic/webhooks-for-zoho-sign

this is the only documentation that can be tested on postman

1 like
Snapey's avatar

You say you can't influence the third party.

It does not matter what you write in the routes file, if they send a GET request then that is what you will need to accept.

They can't look at your routes file and decide, oh, he wants us to submit a POST request !

when I tested this route, I noticed that in the developer tools network tab, the request appears as a GET method instead of a POST

How did you manage to send a POST request from the browser? Did you construct a form with POST method in order to test it, or did you just put the URL in the browser address bar (will always send a GET)

1 like
rommeltraya25's avatar

@Snapey No there's no form with POST method. All I did was to access the url in the browser. Hence, I cannot create form for request because I need this URL to become my Callback URL as webhook. Moreover, I cannot configure the webhook sender for that belongs to another app which I do not have access over it. The other app requires the CALLBACK Url only.

1 like
rommeltraya25's avatar

Additional Info to all:

I only want the URL of the route because I will be needing this as a webhook to another app, which I do not have control of their codes, all they want is the callback URL. With this, the route in the laravel must be in POST to pass the data from the webhook sender. Unfortunately, this error occurs and persists. "The GET method is not supported for route receive-waiver. Supported methods: POST."

1 like
Snapey's avatar
Snapey
Best Answer
Level 122

@rommeltraya25 This error is caused because your method of testing is flawed, not because there is anything wrong with the route.

If you want to test it locally you must use a program like postman

By the way, if the third party wants to send POST (and this would he normal) then you need to EXCLUDE the route from CSRF validation by adding into the except array in verifyCSRF middleware

2 likes
rommeltraya25's avatar

@Snapey Thanks, this clears everything. Also, I already excluded my route in verifyCSRF. Also, I'm not really sure how to test this on Postman.

1 like

Please or to participate in this conversation.