stan3098
stan3098

Reputation: 33

Cannot infer type arguments for ResponseEntity

I am trying to return the response as string from my function using ResponseEntity but getting an error. I tried this:

@GetMapping(value="/getuserip")
public ResponseEntity<Object> getUserData(@RequestParam("username") String userName, HttpServletRequest request){
    String ipAddr = (request.getHeader("X-FORWARDED-FOR"));
    return new ResponseEntity<>(ipAddr, HttpStatus.SC_ACCEPTED);
}

When trying to return the String variable ipAddr I am getting the error. Do you know how to fix this?

Upvotes: 1

Views: 2791

Answers (1)

stan3098
stan3098

Reputation: 33

The library for httpstatus was giving this error in my case. Fixed it by replacing org.apache.http.HttpStatus with org.springframework.http.HttpStatus.

Upvotes: 2

Related Questions