40 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
3
answers
451
views
ResponseEntity: add a body to a 404 Not Found as return in GET Spring Boot Controller
I am developing a Controller in Spring Boot. In case the item is not found in the DB I would like to resurrect a ResponseEntity with Http code of type HttpStatus.NOT_FOUND, but also a message saying ...
1
vote
1
answer
88
views
Read custom HTTP headers sent from Java Spring Boot using Angular, got null
I use Angular to read http header from Java Spring Boot,
It works fine in Postman. I can read all the headers.
But when I use Angular, I got status 200, but null for headers.
Please help. Where did i ...
0
votes
0
answers
37
views
How to Handle Errors with Messages in ResponseEntity in Spring?
How should error responses be handled properly? When I need to return a class, I use ResponseEntity<Class>. However, if I want to return an error as plain text (string), I would need to use ...
1
vote
2
answers
225
views
Rest Template Returns Response in Garbled Characters Some Sort of Chinese
I am using rest template to call API, when I hit the API using rest template it returns some garbled characters like Chinese.
ResponseEntity<String> response = restTemplate.exchange(url, method, ...
-1
votes
1
answer
3k
views
Should I do a check for null for a ResponseEntity<> object in Spring Boot?
I'm working with ResponseEntity<> in a Spring Boot project and I want to know if it's mandatory to check the responseBody object for null before calling getBody()?
For ex:
ResponseEntity<...
0
votes
1
answer
327
views
Stream content from SQL/DAO to Browser in a File using Spring
So I have this problem where I need to return huge SQL results (millions of rows) to the client as a file.
To break the problems, I split them into two:
Streaming SQL results from DAO to Service ...
1
vote
1
answer
2k
views
error attempting to convert the JSON string response from the API to a Map<String, Object>
I am encountering an issue while consuming an API that returns a JSON string. When attempting to convert the JSON string response from the API to a Map<String, Object>, it throws an error. ...
1
vote
1
answer
2k
views
GlobalExceptionHandler with @ExceptionHandler or ResponseEntity for REST answer from the server?
I've found two approaches of returning error status codes from RESTful API: the first is traditional using ResponseEntity<>. The second one is to create specific exceptions for status codes and ...
0
votes
1
answer
68
views
Rest Spring boot converts a response with duplicate object to id of that object
I write a rest spring boot that return List<Map<String,Object>> as response.
public List<Map<String,Object>> getAll(@Valid DataRequestDto dto)
{
List<Map<...
0
votes
0
answers
202
views
StreamingResponseBody body not executing body returning immeditly - but Rest API still in the process of downloading
I have the below code - after executing below code the client getting immediate response with blank zip file (with out having list of files) , however the StreamingResponseBody
Still executing by ...
0
votes
2
answers
335
views
MongoDB returns an empty list when run with Spring Boot Framework
When i run my spring boot application it returns an empty arraylist which i'm at alas on what is going on, because everything looks correct to me, here are my codes
Checkout the images of the classes ...
1
vote
0
answers
109
views
Is using a wildcard (unbounded) instead of Object class a better approach?
I am working on a service has to forward the incoming requests to a destination service after performing some alterations on the object received in the request body and return the response received ...
1
vote
1
answer
1k
views
Cannot invoke "org.springframework.http.ResponseEntity.getBody()" because "responseEntity" is null
In Mockito test cases, I m facing this response entity is null error which ideally should not be happening as I have mocked the response entity as well.
My Code:
Mockito.when(restTemplate.exchange(...
1
vote
2
answers
3k
views
Webclient to return ResponseEntity on error
I never worked with WebClient before, but I have to use it to send a Post request to an external url. After that I check the response status, and if it's 204 I'll continue with the process, but if the ...
0
votes
0
answers
538
views
How to return an InputStreamResource so it can readable from postman?
So I have a method
@GetMapping(
value = "/download/{fileId}",
produces = { MediaType.APPLICATION_OCTET_STREAM_VALUE }
)
public ResponseEntity<...