Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use DELETE OR PUT (400 BadRequest) #16

Closed
jahu opened this issue Dec 14, 2015 · 5 comments
Closed

Cannot use DELETE OR PUT (400 BadRequest) #16

jahu opened this issue Dec 14, 2015 · 5 comments
Assignees

Comments

@jahu
Copy link

jahu commented Dec 14, 2015

I'm wondering why I recieve following result when trying DELETE request on some enttiy:

<HTML>
    <HEAD>
        <TITLE>400 Bad Request</TITLE>
    </HEAD>
    <BODY BGCOLOR=#FFFFFF>
        <H1>400 Bad Request</H1>
    Your browser sent a request that this server could not understand.


    </BODY>
</HTML>

I am trying to use the api from within angularJs controller as well as Postman - same result.

My request is following:

 var req = {
             method: 'DELETE',
             url: 'http://some.application.com/api/api.php/registration/' + $scope.registrationToBeDeleted,
              data: {
               },
              headers: {
                      'Content-Type': 'application/json'
                  }
            };

            $http(req).success(function(data){
                $scope.checkTodayReservations();
            }); 

I've tried to remove headers and data elements - same result.

Could you please help?

@jahu jahu changed the title Cannot use DELETE (400 BadRequest) Cannot use DELETE OR PUT (400 BadRequest) Dec 14, 2015
@jahu
Copy link
Author

jahu commented Dec 14, 2015

The same happens with PUT request.

@mevdschee
Copy link
Owner

Don't send a body on a DELETE. What is the PUT you are trying to execute?

@mevdschee
Copy link
Owner

I don't think the script ever sends a 400:

$ grep header api.php
            header('Content-Type:',true,404);
            header('Content-Type:',true,403);
            header('Content-Type:',true,409);
            header('Content-Type:',true,422);

So, this must have been sent by your web browser (Apache, IIS, nginx).

@mevdschee mevdschee self-assigned this Dec 14, 2015
@jahu
Copy link
Author

jahu commented Dec 14, 2015

I am wondering whether it is not related to my hosting policy. I've tried to use DELETE without payload, the same result. In PUT I've just entered fields I wanted to update in json (+ content type json in request header).

I've overcome this with custom php script for data deletion and update (I need it working now), however I will come back to this issue whenever I will have some spare time.

@mevdschee
Copy link
Owner

Sure, but without any context of your hosting environment it is hard for me to help you. I think you are running IIS, based on your output. In "IIS Manager" go to "Handler Mappings" and click "Edit" on the ".php" handler. Then go to "Request Restrictions" and the "Verbs" tab. Now select the "All verbs" option to allow all verbs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants