Laravel (5.4) throws 404 on valid API route
I've been trying to solve this using various different suggestions but nothing seems to work, and although it's possible I'm missing something really obvious, I just don't understand why I'm getting a 404 error on a route that definitely exists.
I have a CRM that amongst other options allows the user to delete a 'deliverable' (a file attached to a case) but for some reason I always get a 404 when trying to execute it.
Here's the call in the React component:
documentCollectionRepo.removeDeliverable(deliverable.id).then(showSuccess, showError);
deliverable.id
definitely exists, as I have console logged it out.
Here is the function in the repo:
export function removeDeliverable(documentCollectionId) {
return Api.remove(`document-collections/${documentCollectionId}`);
}
And finally, here is the route in the API routes file:
Route::delete('document-collections/{documentCollectionId}', 'DocumentCollectionController@deleteDocumentCollection');
When I click the Delete button to run the relevant function, the Network tab shows the following error (IP hidden in this quote):
Request URL: http://192.168.50.52/api/v1/document-collections/3
Request Method: DELETE
Status Code: 404 Not Found
Remote Address:
192.168.xx.xx:80
Referrer Policy: no-referrer-when-downgrade
The deleteDocumentCollection()
function definitely exists in the DocumentCollectionController.php
file and every other function works (including another delete route) - so I don't quite understand why this route wouldn't work. Any help regarding this would be appreciated.
EDIT:
Here is the controller function:
public function deleteDocumentCollection(DeleteDocumentCollectionRequest $req, $documentCollectionId)
{
$this->documentCollectionRepository->delete($documentCollectionId);
return response()->ok();
}
And in the repo:
public function delete($fileId)
{
$file = $this->getOne($fileId);
$this->deleteUploadedFile($file);
$this->deleteNotifications($file);
$this->deleteNotes($file);
$file->delete();
}
laravel http-status-code-404
add a comment |
I've been trying to solve this using various different suggestions but nothing seems to work, and although it's possible I'm missing something really obvious, I just don't understand why I'm getting a 404 error on a route that definitely exists.
I have a CRM that amongst other options allows the user to delete a 'deliverable' (a file attached to a case) but for some reason I always get a 404 when trying to execute it.
Here's the call in the React component:
documentCollectionRepo.removeDeliverable(deliverable.id).then(showSuccess, showError);
deliverable.id
definitely exists, as I have console logged it out.
Here is the function in the repo:
export function removeDeliverable(documentCollectionId) {
return Api.remove(`document-collections/${documentCollectionId}`);
}
And finally, here is the route in the API routes file:
Route::delete('document-collections/{documentCollectionId}', 'DocumentCollectionController@deleteDocumentCollection');
When I click the Delete button to run the relevant function, the Network tab shows the following error (IP hidden in this quote):
Request URL: http://192.168.50.52/api/v1/document-collections/3
Request Method: DELETE
Status Code: 404 Not Found
Remote Address:
192.168.xx.xx:80
Referrer Policy: no-referrer-when-downgrade
The deleteDocumentCollection()
function definitely exists in the DocumentCollectionController.php
file and every other function works (including another delete route) - so I don't quite understand why this route wouldn't work. Any help regarding this would be appreciated.
EDIT:
Here is the controller function:
public function deleteDocumentCollection(DeleteDocumentCollectionRequest $req, $documentCollectionId)
{
$this->documentCollectionRepository->delete($documentCollectionId);
return response()->ok();
}
And in the repo:
public function delete($fileId)
{
$file = $this->getOne($fileId);
$this->deleteUploadedFile($file);
$this->deleteNotifications($file);
$this->deleteNotes($file);
$file->delete();
}
laravel http-status-code-404
Could you also post the group(s) by which this route is surrounded? And does your laravel log contain any errors?
– Sven Hakvoort
Nov 22 '18 at 15:21
All the routes are wrapped inRoute::group(['middleware' => ['auth', 'store-last-active']], function() {
group and no, there are no additional errors in the log, just the 404
– Michael Emerson
Nov 23 '18 at 16:11
add a comment |
I've been trying to solve this using various different suggestions but nothing seems to work, and although it's possible I'm missing something really obvious, I just don't understand why I'm getting a 404 error on a route that definitely exists.
I have a CRM that amongst other options allows the user to delete a 'deliverable' (a file attached to a case) but for some reason I always get a 404 when trying to execute it.
Here's the call in the React component:
documentCollectionRepo.removeDeliverable(deliverable.id).then(showSuccess, showError);
deliverable.id
definitely exists, as I have console logged it out.
Here is the function in the repo:
export function removeDeliverable(documentCollectionId) {
return Api.remove(`document-collections/${documentCollectionId}`);
}
And finally, here is the route in the API routes file:
Route::delete('document-collections/{documentCollectionId}', 'DocumentCollectionController@deleteDocumentCollection');
When I click the Delete button to run the relevant function, the Network tab shows the following error (IP hidden in this quote):
Request URL: http://192.168.50.52/api/v1/document-collections/3
Request Method: DELETE
Status Code: 404 Not Found
Remote Address:
192.168.xx.xx:80
Referrer Policy: no-referrer-when-downgrade
The deleteDocumentCollection()
function definitely exists in the DocumentCollectionController.php
file and every other function works (including another delete route) - so I don't quite understand why this route wouldn't work. Any help regarding this would be appreciated.
EDIT:
Here is the controller function:
public function deleteDocumentCollection(DeleteDocumentCollectionRequest $req, $documentCollectionId)
{
$this->documentCollectionRepository->delete($documentCollectionId);
return response()->ok();
}
And in the repo:
public function delete($fileId)
{
$file = $this->getOne($fileId);
$this->deleteUploadedFile($file);
$this->deleteNotifications($file);
$this->deleteNotes($file);
$file->delete();
}
laravel http-status-code-404
I've been trying to solve this using various different suggestions but nothing seems to work, and although it's possible I'm missing something really obvious, I just don't understand why I'm getting a 404 error on a route that definitely exists.
I have a CRM that amongst other options allows the user to delete a 'deliverable' (a file attached to a case) but for some reason I always get a 404 when trying to execute it.
Here's the call in the React component:
documentCollectionRepo.removeDeliverable(deliverable.id).then(showSuccess, showError);
deliverable.id
definitely exists, as I have console logged it out.
Here is the function in the repo:
export function removeDeliverable(documentCollectionId) {
return Api.remove(`document-collections/${documentCollectionId}`);
}
And finally, here is the route in the API routes file:
Route::delete('document-collections/{documentCollectionId}', 'DocumentCollectionController@deleteDocumentCollection');
When I click the Delete button to run the relevant function, the Network tab shows the following error (IP hidden in this quote):
Request URL: http://192.168.50.52/api/v1/document-collections/3
Request Method: DELETE
Status Code: 404 Not Found
Remote Address:
192.168.xx.xx:80
Referrer Policy: no-referrer-when-downgrade
The deleteDocumentCollection()
function definitely exists in the DocumentCollectionController.php
file and every other function works (including another delete route) - so I don't quite understand why this route wouldn't work. Any help regarding this would be appreciated.
EDIT:
Here is the controller function:
public function deleteDocumentCollection(DeleteDocumentCollectionRequest $req, $documentCollectionId)
{
$this->documentCollectionRepository->delete($documentCollectionId);
return response()->ok();
}
And in the repo:
public function delete($fileId)
{
$file = $this->getOne($fileId);
$this->deleteUploadedFile($file);
$this->deleteNotifications($file);
$this->deleteNotes($file);
$file->delete();
}
laravel http-status-code-404
laravel http-status-code-404
edited Nov 22 '18 at 13:04
Michael Emerson
asked Nov 22 '18 at 10:26
Michael EmersonMichael Emerson
73911032
73911032
Could you also post the group(s) by which this route is surrounded? And does your laravel log contain any errors?
– Sven Hakvoort
Nov 22 '18 at 15:21
All the routes are wrapped inRoute::group(['middleware' => ['auth', 'store-last-active']], function() {
group and no, there are no additional errors in the log, just the 404
– Michael Emerson
Nov 23 '18 at 16:11
add a comment |
Could you also post the group(s) by which this route is surrounded? And does your laravel log contain any errors?
– Sven Hakvoort
Nov 22 '18 at 15:21
All the routes are wrapped inRoute::group(['middleware' => ['auth', 'store-last-active']], function() {
group and no, there are no additional errors in the log, just the 404
– Michael Emerson
Nov 23 '18 at 16:11
Could you also post the group(s) by which this route is surrounded? And does your laravel log contain any errors?
– Sven Hakvoort
Nov 22 '18 at 15:21
Could you also post the group(s) by which this route is surrounded? And does your laravel log contain any errors?
– Sven Hakvoort
Nov 22 '18 at 15:21
All the routes are wrapped in
Route::group(['middleware' => ['auth', 'store-last-active']], function() {
group and no, there are no additional errors in the log, just the 404– Michael Emerson
Nov 23 '18 at 16:11
All the routes are wrapped in
Route::group(['middleware' => ['auth', 'store-last-active']], function() {
group and no, there are no additional errors in the log, just the 404– Michael Emerson
Nov 23 '18 at 16:11
add a comment |
1 Answer
1
active
oldest
votes
If you Laravel Project is configured on Apache, then it might occur such issue.
Because Apache doesn't allow DELETE requests, so the response will be 404.
Add this to .htaccess after the Laravel default codes:
<Limit DELETE>
Order deny,allow
Allow from all
</Limit>
Again this can be the possible case. and if it still don't work, please share your code in brief so i can look into it.
Thanks.
Actually I use nginx, and also as I stated in my question all other delete requests work fine - it's literally just that one
– Michael Emerson
Nov 22 '18 at 12:37
Can you please only share code ofdeleteDocumentCollection()
function ?
– dvl333
Nov 22 '18 at 12:39
I have added them to the question
– Michael Emerson
Nov 22 '18 at 13:04
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53428828%2flaravel-5-4-throws-404-on-valid-api-route%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you Laravel Project is configured on Apache, then it might occur such issue.
Because Apache doesn't allow DELETE requests, so the response will be 404.
Add this to .htaccess after the Laravel default codes:
<Limit DELETE>
Order deny,allow
Allow from all
</Limit>
Again this can be the possible case. and if it still don't work, please share your code in brief so i can look into it.
Thanks.
Actually I use nginx, and also as I stated in my question all other delete requests work fine - it's literally just that one
– Michael Emerson
Nov 22 '18 at 12:37
Can you please only share code ofdeleteDocumentCollection()
function ?
– dvl333
Nov 22 '18 at 12:39
I have added them to the question
– Michael Emerson
Nov 22 '18 at 13:04
add a comment |
If you Laravel Project is configured on Apache, then it might occur such issue.
Because Apache doesn't allow DELETE requests, so the response will be 404.
Add this to .htaccess after the Laravel default codes:
<Limit DELETE>
Order deny,allow
Allow from all
</Limit>
Again this can be the possible case. and if it still don't work, please share your code in brief so i can look into it.
Thanks.
Actually I use nginx, and also as I stated in my question all other delete requests work fine - it's literally just that one
– Michael Emerson
Nov 22 '18 at 12:37
Can you please only share code ofdeleteDocumentCollection()
function ?
– dvl333
Nov 22 '18 at 12:39
I have added them to the question
– Michael Emerson
Nov 22 '18 at 13:04
add a comment |
If you Laravel Project is configured on Apache, then it might occur such issue.
Because Apache doesn't allow DELETE requests, so the response will be 404.
Add this to .htaccess after the Laravel default codes:
<Limit DELETE>
Order deny,allow
Allow from all
</Limit>
Again this can be the possible case. and if it still don't work, please share your code in brief so i can look into it.
Thanks.
If you Laravel Project is configured on Apache, then it might occur such issue.
Because Apache doesn't allow DELETE requests, so the response will be 404.
Add this to .htaccess after the Laravel default codes:
<Limit DELETE>
Order deny,allow
Allow from all
</Limit>
Again this can be the possible case. and if it still don't work, please share your code in brief so i can look into it.
Thanks.
answered Nov 22 '18 at 12:34
dvl333dvl333
495
495
Actually I use nginx, and also as I stated in my question all other delete requests work fine - it's literally just that one
– Michael Emerson
Nov 22 '18 at 12:37
Can you please only share code ofdeleteDocumentCollection()
function ?
– dvl333
Nov 22 '18 at 12:39
I have added them to the question
– Michael Emerson
Nov 22 '18 at 13:04
add a comment |
Actually I use nginx, and also as I stated in my question all other delete requests work fine - it's literally just that one
– Michael Emerson
Nov 22 '18 at 12:37
Can you please only share code ofdeleteDocumentCollection()
function ?
– dvl333
Nov 22 '18 at 12:39
I have added them to the question
– Michael Emerson
Nov 22 '18 at 13:04
Actually I use nginx, and also as I stated in my question all other delete requests work fine - it's literally just that one
– Michael Emerson
Nov 22 '18 at 12:37
Actually I use nginx, and also as I stated in my question all other delete requests work fine - it's literally just that one
– Michael Emerson
Nov 22 '18 at 12:37
Can you please only share code of
deleteDocumentCollection()
function ?– dvl333
Nov 22 '18 at 12:39
Can you please only share code of
deleteDocumentCollection()
function ?– dvl333
Nov 22 '18 at 12:39
I have added them to the question
– Michael Emerson
Nov 22 '18 at 13:04
I have added them to the question
– Michael Emerson
Nov 22 '18 at 13:04
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53428828%2flaravel-5-4-throws-404-on-valid-api-route%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Could you also post the group(s) by which this route is surrounded? And does your laravel log contain any errors?
– Sven Hakvoort
Nov 22 '18 at 15:21
All the routes are wrapped in
Route::group(['middleware' => ['auth', 'store-last-active']], function() {
group and no, there are no additional errors in the log, just the 404– Michael Emerson
Nov 23 '18 at 16:11