2
$http.post(main+'/api/getcard/', $.param({number: $scope.searchcard}), {headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'} })
        .then(function (response) {
            if(response.data != 0)
            {
                $location.path('/redeem/'+response.data.id);
                console.log(response.data);
            }
        });

When i use this code my chrome sends:

Request URL:http://cards.mporeda.pl/branch/api/getcard
Request Method:GET
Status Code:405 Method Not Allowed

But when i use the same code on laravel serve localhost:8000 i get:

Request URL:http://localhost:8000/branch/api/getcard/
Request Method:POST
Status Code:200 OK

I don't have any more $http configurations only this header option in request. I have no errors on console before this request, so i quess my code is ok. Is there any problem with my server or something?

1
  • You should use data instead of param when you are using POST Commented Mar 18, 2017 at 11:15

1 Answer 1

8

The URL your code says to make the request to is:

main+'/api/getcard/'

The URL your request says you are using is:

Request URL:http://cards.mporeda.pl/branch/api/getcard

This is most likely caused by:

  1. you making a POST request to the URL you are trying to make a POST request to
  2. the server responding with a 301 or 302 status and a Location header that redirects to the same URL without the / on the end
  3. the browser following the redirect and making a GET request

If you look back up your list of requests, you should see the POST request.

To resolve this, you need to look at the server side code which is issuing the redirect.

Sign up to request clarification or add additional context in comments.

1 Comment

In my case i had a double // in between. Ex: 127.0.0.1//oauth/token , note the // before the oauth, my web server was issuing a Location redirect, but Chrome Dev Tools only displayed the GET request

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.