79531235

Date: 2025-03-24 13:44:43
Score: 1.5
Natty:
Report link

I finally found the issue thanks to this github issue: when using a Form Request Validator you need to add this header

Accept: application/json

in order to Laravel to find the controller’s method.

TL;DR

// With a "Form Request Validator", the header "Accept: application/json" is mandatory, otherwise 404
public function store(StoreMovieRequest $request) {}

// With the model directly, the method/route is found even if header "Accept: application/json" is missing
public function store(Movie $movie) {}

In Postman: Screenshot of the header in Postman

Reasons:
  • Blacklisted phrase (0.5): thanks
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: lavalade