Join the Stack Overflow Community
Stack Overflow is a community of 6.5 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I have next method to get request:

public ResponseEntity getPagingNews(@RequestBody Paging paging, HttpServletRequest request) {
    LanguageService.setLanguage(request);
    List<News> news = newsDao.pagination(paging.getTake(), paging.getSkip());
    if (news != null) {
        return new ResponseEntity<>(news, HttpStatus.OK);
    }
    return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}


public class LanguageService {

public static String lang = "ru-RU";

public static void setLanguage(HttpServletRequest request) {
    Cookie[] cookies = request.getCookies();
    for (Cookie cookie : cookies) {
        if (cookie.getName().equals("mainLang")) {
            if (!lang.equals(cookie.getValue())) {
                LanguageService.lang = cookie.getValue();
            }
        }
      }
    }

}

If i send request with postman or swagger all works great, but if I send it with angularjs i have returned 400 code Bad Request and my @RequestBody is null.
And angular js always send http request twice on server.

share
    
400 means the request could not be understood by the server......this may causes because of bad syntax. – Sa E Chowdary 2 mins ago
    
you'd better append your angular js code as well. – dursun 2 mins ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.