Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect 302 on Laravel POST request

Tags:

php

laravel

api

I'm developing a Laravel Web Service. When I try my POST routes with web forms, everything works fine, but when I try the same with a REST Client like Postman it doesn't get me the response that should.

It gives me status code 302, and redirects to "/". What's the problem?

like image 364
Bellots Avatar asked May 18 '15 07:05

Bellots


People also ask

How do you resolve a 302 redirect?

You can follow these five steps to fix HTTP 302 errors on your website: Determine whether the redirects are appropriate or not by examining the URLs that are issuing the 302 redirects. Check your plugins to make sure any redirect settings are valid. Ensure that your WordPress URL settings are configured correctly.

Does a 302 automatically redirect?

What is an HTTP 302? The 302 status code is a redirection message that occurs when a resource or page you're attempting to load has been temporarily moved to a different location. It's usually caused by the web server and doesn't impact the user experience, as the redirect happens automatically.

What is 302 error in laravel?

302 response status code is not an error. Everything is OK. That means that route to which successful login should be redirected has been found.

Why do we get 302 error?

A redirect 302 is a code that tells visitors of a specific URL that the page has been moved temporarily, directing them directly to the new location. In other words, redirect 302 is activated when Google robots or other search engines request to load a specific page.


1 Answers

This might be useful for other users that having the same problem cannot solve it with the accepted solution.

Make sure that the form fields names for instance <input type="text" name="document_name"> (document_name), match the names of the rules fields declared in the model.
public static $rules = ['document_name' => 'required|string'];
It doesn't throw any errors, nothing in the logs, it just redirects to the form, therefore the difficulty to find the problem.

like image 199
achasinh Avatar answered Nov 08 '22 03:11

achasinh