Deepesh Rathore
Deepesh Rathore

Reputation: 351

Request Body with Content-Type: application/x-www-form-urlencoded;charset=UTF-8 Not working

How to have post mapping in controller, when content type is application/x-www-form-urlencoded;charset=utf-8 and request body has text or application/json. I have read that @requestbody does not work with urlencoded. How to reslove this issue.

Upvotes: 0

Views: 1545

Answers (1)

Mikred
Mikred

Reputation: 98

@CrossOrigin
@ResponseBody
@PostMapping
public Book addBook(@RequestBody Book newBook){
    Book book = new Book(newBook.getTitle());
    bookRepository.save(book);
    return book;
}

An example, it works

Upvotes: 0

Related Questions