2015-05-21 85 views
6

嗨我正面臨角度http post方法的問題。如果我嘗試使用angularjs http發送數據,它會將數據作爲查詢字符串發送。當我傳遞非常大的數據時,它給了我一個錯誤:服務器響應的狀態爲414(Request-URI太長)。angularjs http post方法將數據作爲查詢字符串發送?

這裏是我的HTTP POST工廠方法:

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 

    }); 
}; 

爲什麼我的數據,即使使用Post方法後,作爲查詢字符串參數發送?

回答

11

認沽PARAMS數據關鍵..

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

}); 

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

+0

在這種情況下,我要趕在InsertInAdditionalDataDetailsIdBulk方法右單參數好嗎? –

相關問題