Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angularjs http post method sends data as a query string?

Hi I am facing issue over angular http post method. If i try to send data using angularjs http post it sends data as a query string. as I am passing very huge data it gives me error : the server responded with a status of 414 (Request-URI Too Long).

here is my http post factory method:

dataFactory.InsertInAdditionalDataDetailsIdBulk = function (AdditionalDataDetailsIds, AdditionalDataID,
                                                   AdditionalDataName, AdditionalDataDate) {
    var params = {
        AdditionalDataDetailsIds: AdditionalDataDetailsIds,
        AdditionalDataID: AdditionalDataID,
        AdditionalDataName: AdditionalDataName,
        AdditionalDataDate: AdditionalDataDate
    }
    return $http({
        url: '/GroupsManager/InsertInAdditionalDataDetailsIdBulk',
        method: 'POST',
        params: params

    });
};

Why my data is sent as query string parameter even after using Post method?

like image 303
Samir Shah Avatar asked May 21 '15 03:05

Samir Shah


1 Answers

Put params in the data key..

return $http({
    url: '/GroupsManager/InsertInAdditionalDataDetailsIdBulk',
    method: 'POST',
    data: params

});

https://docs.angularjs.org/api/ng/service/$http

like image 167
user3227295 Avatar answered Sep 18 '22 10:09

user3227295