3

Angular:

function(team, team) { return this.http.put('/api/tradeTeam/', team, 
     team2).map(res => res.json()); }

Spring/Hibernate

@RestController
@Controller
public class MainController {
    @RequestMapping(value = "/api/tradeTeam/", method = RequestMethod.PUT)  
    public List<Team> TradeTeam(@RequestBody Team team, Team team2) {       
        return teamService.TradeTeam(team, team2);      
    }
}

What am I doing wrong? My Service is set up correctly.
My error is:

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause

1
  • 1
    for put request , the third parameter is of options . you are passing your parameter there which is wrong . Commented Nov 30, 2018 at 10:29

1 Answer 1

1

The problem is that you are passing the team2 as a third parameter for the http.put function, which is taken as options (not for body where you need it).

You should send something like that (and I think this will need some more work also on the backend)

function(team, team2) { 
    return this.http.put('/api/tradeTeam/', {teams: [team, team2]})
       .map(res => res.json()); 
}

See: Angular HTTP Client Docs

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.