1

I have Java API function as bellow :

     public Response abc(@FormParam("tenderIdsJsonArray") JSONArray tenderIdsJsonArray, @FormParam("tenderRejectTime") String tenderRejectTime,@FormParam("rejectResonType")  String rejectResonType) {

     }

I am sending data from AngularJs

     $http({
      method: 'POST',
      url: URL,
      data: {bacJsonArray:[1543],RejectTime:"12",rejectResonType:"test"}    
    }).success(function (response) {
      loaderServ.hide();
      resolve(response);
    }).error(function (error) {
      loaderServ.hide();
      reject(error);
    });

I am getting all parameters of function as null at API side

where i need to make change

I also tried sending:

JSON.stringify({bacJsonArray:[1543],RejectTime:"12",rejectResonType:"test"} 
    })

or params:{alldata}

I also tried changing at server side:

     public Response abc(JSONArray bacJsonArray,String RejectTime,String rejectResonType) {

     }

But in all cases i am recieving Null at server side

2 Answers 2

1

Below way i used and it worked.

    $http({
        method: 'POST',
        url: url,
        headers: {'Content-Type': 'application/x-www-form-urlencoded'},
        transformRequest: function(obj) {
            var str = [];
            for(var p in obj)
            str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
            return str.join("&");
        },
        data: {username: $scope.userName, password: $scope.password}
    }).success(function () {});
Sign up to request clarification or add additional context in comments.

Comments

0
var req = {
    method: 'POST',
    url: 'http://example.com',
    data: { test: 'test' }
};

$http(req).then(function(){
    // success
}, function(){
    error
});

6 Comments

can yo give me in above case $http({ method: 'POST',
@pareshm what are you saying ?
dont want in shorthand form
@pareshm i don't know about JAVA but passing params to a function is a GET not POST right ? have you tried $http.get instead of $http.post ?
@pareshm did it help ?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.