Issue Details
I am using Laravel 8. There is a patch route. I am trying to submit the patch request through postman. Due to some reasons it shows 404 response.
Please let me know if you need more information.
Laravel Route
use App\Http\Controllers\User\Role\RoleApiController;
Route::patch("update-role/{role_id}", [
RoleApiController::class,
"Update"
])->name("UpdateRoleApi");
Route Proof in console
Controller
class RoleApiController extends Controller {
public function Update(UpdateRoleRequest $request, $role_id) {
return \Response::json([], 200);
}
}
Request
class UpdateRoleRequest extends FormRequest {
public function wantsJson() {
return true;
}
public function rules() {
return [
"role_id" => "required",
"role" => "required"
];
}
}
Postman request
PostMan Patch Request Logs
PATCH http://192.168.1.3:1234/My/learning/1/backend/Laravel/practise1/public/api/v1/update-role?api_token=token/role_id: {
"Network": {
"addresses": {
"local": {
"address": "192.168.1.3",
"family": "IPv4",
"port": 54995
},
"remote": {
"address": "192.168.1.3",
"family": "IPv4",
"port": 1234
}
}
},
"Request Headers": {
"accept": "application/json",
"content-type": "application/json",
"user-agent": "PostmanRuntime/7.29.2",
"postman-token": "c277824a-093d-4324-a17c-84a033e91719",
"host": "192.168.1.3:1234",
"accept-encoding": "gzip, deflate, br",
"connection": "keep-alive",
"content-length": "36"
},
"Request Body": "{\"role\": \"Test ABC A\", \"role_id\": 2}",
"Response Headers": {
"date": "Thu, 06 Oct 2022 07:59:23 GMT",
"server": "Apache/2.4.53 (Win64) OpenSSL/1.1.1n PHP/7.4.29",
"x-powered-by": "PHP/7.4.29",
"cache-control": "no-cache, private",
"access-control-allow-origin": "*",
"connection": "close",
"content-type": "application/json"
},
"Response Body": "{\n \"message\": \"\",\n \"exception\": \"Symfony\\\\Component\\\\HttpKernel\\\\Exception\\\\NotFoundHttpException\",\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Routing\\\\AbstractRouteCollection.php\",\n \"line\": 43,\n \"trace\": [\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Routing\\\\RouteCollection.php\",\n \"line\": 162,\n \"function\": \"handleMatchedRoute\",\n \"class\": \"Illuminate\\\\Routing\\\\AbstractRouteCollection\",\n \"type\": \"->\"\n },\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Routing\\\\Router.php\",\n \"line\": 673,\n \"function\": \"match\",\n \"class\": \"Illuminate\\\\Routing\\\\RouteCollection\",\n \"type\": \"->\"\n },\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Routing\\\\Router.php\",\n \"line\": 662,\n \"function\": \"findRoute\",\n \"class\": \"Illuminate\\\\Routing\\\\Router\",\n \"type\": \"->\"\n },\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Routing\\\\Router.php\",\n \"line\": 651,\n \"function\": \"dispatchToRoute\",\n \"class\": \"Illuminate\\\\Routing\\\\Router\",\n \"type\": \"->\"\n },\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Foundation\\\\Http\\\\Kernel.php\",\n \"line\": 167,\n \"function\": \"dispatch\",\n \"class\": \"Illuminate\\\\Routing\\\\Router\",\n \"type\": \"->\"\n },\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Pipeline\\\\Pipeline.php\",\n \"line\": 128,\n \"function\": \"Illuminate\\\\Foundation\\\\Http\\\\{closure}\",\n \"class\": \"Illuminate\\\\Foundation\\\\Http\\\\Kernel\",\n \"type\": \"->\"\n },\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Foundation\\\\Http\\\\Middleware\\\\TransformsRequest.php\",\n \"line\": 21,\n \"function\": \"Illuminate\\\\Pipeline\\\\{closure}\",\n \"class\": \"Illuminate\\\\Pipeline\\\\Pipeline\",\n \"type\": \"->\"\n },\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Foundation\\\\Http\\\\Middleware\\\\ConvertEmptyStringsToNull.php\",\n \"line\": 31,\n \"function\": \"handle\",\n \"class\": \"Illuminate\\\\Foundation\\\\Http\\\\Middleware\\\\TransformsRequest\",\n \"type\": \"->\"\n },\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Pipeline\\\\Pipeline.php\",\n \"line\": 167,\n \"function\": \"handle\",\n \"class\": \"Illuminate\\\\Foundation\\\\Http\\\\Middleware\\\\ConvertEmptyStringsToNull\",\n \"type\": \"->\"\n },\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Foundation\\\\Http\\\\Middleware\\\\TransformsRequest.php\",\n \"line\": 21,\n \"function\": \"Illuminate\\\\Pipeline\\\\{closure}\",\n \"class\": \"Illuminate\\\\Pipeline\\\\Pipeline\",\n \"type\": \"->\"\n },\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Foundation\\\\Http\\\\Middleware\\\\TrimStrings.php\",\n \"line\": 40,\n \"function\": \"handle\",\n \"class\": \"Illuminate\\\\Foundation\\\\Http\\\\Middleware\\\\TransformsRequest\",\n \"type\": \"->\"\n },\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Pipeline\\\\Pipeline.php\",\n \"line\": 167,\n \"function\": \"handle\",\n \"class\": \"Illuminate\\\\Foundation\\\\Http\\\\Middleware\\\\TrimStrings\",\n \"type\": \"->\"\n },\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Foundation\\\\Http\\\\Middleware\\\\ValidatePostSize.php\",\n \"line\": 27,\n \"function\": \"Illuminate\\\\Pipeline\\\\{closure}\",\n \"class\": \"Illuminate\\\\Pipeline\\\\Pipeline\",\n \"type\": \"->\"\n },\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Pipeline\\\\Pipeline.php\",\n \"line\": 167,\n \"function\": \"handle\",\n \"class\": \"Illuminate\\\\Foundation\\\\Http\\\\Middleware\\\\ValidatePostSize\",\n \"type\": \"->\"\n },\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Foundation\\\\Http\\\\Middleware\\\\PreventRequestsDuringMaintenance.php\",\n \"line\": 86,\n \"function\": \"Illuminate\\\\Pipeline\\\\{closure}\",\n \"class\": \"Illuminate\\\\Pipeline\\\\Pipeline\",\n \"type\": \"->\"\n },\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Pipeline\\\\Pipeline.php\",\n \"line\": 167,\n \"function\": \"handle\",\n \"class\": \"Illuminate\\\\Foundation\\\\Http\\\\Middleware\\\\PreventRequestsDuringMaintenance\",\n \"type\": \"->\"\n },\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\fruitcake\\\\laravel-cors\\\\src\\\\HandleCors.php\",\n \"line\": 52,\n \"function\": \"Illuminate\\\\Pipeline\\\\{closure}\",\n \"class\": \"Illuminate\\\\Pipeline\\\\Pipeline\",\n \"type\": \"->\"\n },\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Pipeline\\\\Pipeline.php\",\n \"line\": 167,\n \"function\": \"handle\",\n \"class\": \"Fruitcake\\\\Cors\\\\HandleCors\",\n \"type\": \"->\"\n },\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Http\\\\Middleware\\\\TrustProxies.php\",\n \"line\": 39,\n \"function\": \"Illuminate\\\\Pipeline\\\\{closure}\",\n \"class\": \"Illuminate\\\\Pipeline\\\\Pipeline\",\n \"type\": \"->\"\n },\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Pipeline\\\\Pipeline.php\",\n \"line\": 167,\n \"function\": \"handle\",\n \"class\": \"Illuminate\\\\Http\\\\Middleware\\\\TrustProxies\",\n \"type\": \"->\"\n },\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Pipeline\\\\Pipeline.php\",\n \"line\": 103,\n \"function\": \"Illuminate\\\\Pipeline\\\\{closure}\",\n \"class\": \"Illuminate\\\\Pipeline\\\\Pipeline\",\n \"type\": \"->\"\n },\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Foundation\\\\Http\\\\Kernel.php\",\n \"line\": 142,\n \"function\": \"then\",\n \"class\": \"Illuminate\\\\Pipeline\\\\Pipeline\",\n \"type\": \"->\"\n },\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Foundation\\\\Http\\\\Kernel.php\",\n \"line\": 111,\n \"function\": \"sendRequestThroughRouter\",\n \"class\": \"Illuminate\\\\Foundation\\\\Http\\\\Kernel\",\n \"type\": \"->\"\n },\n {\n \"file\": \"C:\\\\xampp\\\\htdocs\\\\My\\\\learning\\\\1\\\\backend\\\\Laravel\\\\practise1\\\\public\\\\index.php\",\n \"line\": 52,\n \"function\": \"handle\",\n \"class\": \"Illuminate\\\\Foundation\\\\Http\\\\Kernel\",\n \"type\": \"->\"\n }\n ]\n}"
}
CodePudding user response:
You have passed the wrong endpoint URL. The postman URL should be update-role/{role_id}?api_token={token}
instead of update-role?api_token={token}/{role_id}
.
CodePudding user response:
You have passed the wrong endpoint URL. The postman URL should be update-role/{role_id}?api_token={token} instead of update-role?api_token={token}/{role_id}.