Tahreem Iqbal Tahreem Iqbal - 3 months ago 11
AngularJS Question

Restful Service Error: Procedure or function expects parameter which was not supplied

I've written a GET service in Restful that takes 3 string parameters and passes them on to an SP. When I call the service from URL it successfully returns the result. But when I call this service from AngularJS in JSON format, it gives the mentioned error.

Here is my Service signature:

[WebInvoke(Method = "GET",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "GetConsignment?cnRefNo={cnRefNo}&branchCode={branchCode}&clientId={clientId}")]
CustomConsignment GetConsignment(string cnRefNo, string branchCode, string clientId);

This is how I call service in AngularJS:

function GetConsignment()
var param = "";
param += '{"cnRefNo":"' + $scope.txtOrderRefNo + '",';
param += '"branchCode":"' + $rootScope.BTSUserCustomObj.BranchCode + '",';
param += '"clientId":"' + $scope.CreditClient.ClientId + '"';
param += '}';


var jsonObj = JSON.parse(param);

method: 'GET',
url: 'https://localhost:4433/MyService/MyService.svc/GetConsignment',
data: jsonObj,
headers: { "Content-Type": 'application/json; charset=utf-8' }
}).success(function (response) {


}).error(function (error) {

I have checked JSON obj in alert and all values are correctly being passed to the service, but it's still giving error.
Any help will be appreciated. Thanks.


Change your Angular call to send value parameters via "params" property instead of "data" parameter to $http. Just like this

        method: 'GET',
        url: 'https://localhost:4433/MyService/MyService.svc/GetConsignment',
        params: jsonObj,
        headers: { "Content-Type": 'application/json; charset=utf-8' }
    }).success(function (response) {