0

I have a spring restful backend, one of the mapping is this:

    @RequestMapping("/getPeopleList")
    public List<Person> getPeeps(@RequestParam(value="ssid", required=true) Integer ssid){
    return Backend.getPeople(ssid);
   }

How do i make a request to this api? I am doing this with my angularjs

   $http.get(url+'/getPeopleList').success(function(peeps) {

        console.log(peeps);
    });

but this doesnt work...... I also tried this

     $http.get(url+'/getPeopleList/234').success(function(peeps) {

        console.log(peeps);
    });

The id 234 is a random id but that doesn;'t work either. I get 404 or 400 bad request everytime .

4
  • 1
    what error you are getting in console ? Commented Nov 28, 2015 at 18:11
  • @swapnesh "Failed to load resource: the server responded with a status of 400 (Bad Request)" This is for the first http request Commented Nov 28, 2015 at 18:12
  • 1
    can you check that the url is forming correctly and headers are properly set ? Commented Nov 28, 2015 at 18:24
  • @swapnesh url was wrong lol Commented Nov 28, 2015 at 18:37

1 Answer 1

1

you are asking for @RequestParam but you are passing @PathVariable. Please see their doc. Just change to :

 $http.get(url+'/getPeopleList?ssid=234').success(function(peeps) {
        console.log(peeps);
    });
Sign up to request clarification or add additional context in comments.

Comments

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.