Cannot infer type arguments for ResponseEntity

2.2k Views Asked by At

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?

1

There are 1 best solutions below

0
On

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