1

I need to send list of Long objects from Angular to Rest controller in Spring boot :

@PostMapping("/accept-friends")
    public ResponseEntity<Void> acceptFriendRequests(@RequestBody List<Long> friendRequestsIds)

Is this possible ?

user3364181
  • 531
  • 3
  • 14
  • 32

3 Answers3

1

Yes this is possible and will work fine.

@PostMapping("/accept-friends")
public ResponseEntity<?> acceptFriendRequests(@RequestBody List<Long> friendRequestsIds) {
  return new ResponseEntity<>(HttpStatus.OK)
}
kj007
  • 6,073
  • 4
  • 29
  • 47
0

Here you have code in Angular 6:

getData(friendRequestsIds: number[]) {
    return this.http.post<Question>('/accept-friends', friendRequestsIds);
}
Bartek
  • 2,109
  • 6
  • 29
  • 40
0

You can use it like this:

@PostMapping("/listData")
public ResponseEntity<Object> listData(@RequestBody List<?> completeList) {
  return new ResponseEntity<Object>(HttpStatus.OK)
}

As I know, you can't keep the ResponseEntity<void>

I hope this will help.

Pawan Tiwari
  • 518
  • 6
  • 26