Pmasterzz
Pmasterzz

Reputation: 21

Error 405 (Method not allowed)

I'm trying to post a form using angularJs with the $http.post method. But whenever i execute this function it gives me this error: Failed to load resource: the server responded with a status of 405 (Method Not Allowed) I have no clue what to do. (Im using visual studio 2015)

 $scope.addRow = function () {
        var parameter = JSON.stringify({ id: 99, first_name: $scope.firstName, last_name: $scope.lastName, email: $scope.email, country: $scope.country, phone_number: $scope.phoneNumber });
        $http.post('MOCK_DATA.json', parameter).success(function (data, status, headers, config) {
            console.log(data);
        })

Upvotes: 2

Views: 2683

Answers (2)

JonathanTheBrosh
JonathanTheBrosh

Reputation: 208

I think I 've often had this problem because the parameters of the query that does not pass. Try something like this:

$http({
     url: '/api/customers/GetFilteredList',
     params: { 
        'lastName': lastName,
        'firstName': firstName,
        'address': address,
        'town': town,
        'zipCode': zipCode,
        'skip': skip,
        'take': take 
     } 
 });

Upvotes: 0

Deblaton Jean-Philippe
Deblaton Jean-Philippe

Reputation: 11398

You have a file : 'MOCK_DATA.json'. The only thing you are allowed to do with this file is retrieving it from your client. (Http Verb 'GET').

If you want to update this file to add values, you must create a controller that will receive your object. Inside this controller you will have to write new lines into your file.

Upvotes: 2

Related Questions