Papa Tom Papa Tom - 17 days ago 7
AngularJS Question

How to pass parameter on [WebMethod] through POST request

I'm trying to pass the

params
"hello" to the
[WebMethod]
. However, for unknown reason it returns an error of
Invalid web service call, missing value for parameter: 'data'
. Why is that? In which part is the error?

Web service

[WebMethod]
public string GetData(string data)
{ return "success"; }


Javascript

$http.post("somelocation/GetData",{
headers:{
"Content-Type":"application/json;"
},
params:{data:"hello"},
data:{}
}

Answer

params is for setting query string in a url , use data option for post data. See $http docs for further detail

Comments