Skip to content
Advertisement

Tag: rest

Mapping nested JSON values in a Java class

I can’t figure out how to handle nested JSON values in my Java classes. To make it simple as possible, I created four Java classes with every ‘nested level’. However, I’m trying to have all these values in one Java class. How can I do this? Json: Java classes: Answer You can club all the supporting classes in one class

How to properly filter Spring REST data

I have a Spring Data REST service with a single @Entity and Repository. When I run $ curl localhost:8080/api I get all the data stored in my repository and it works as expected. I also have a small React front end and I display that data there. My question is: Where should I filter the data? For example maybe I

Passing List in @RequestHeader Restapi

I want to pass list of string in my controller via Request Header @RequestHeader(“list”) final List<String> listOfString. Can this be used. How can I pass list of string in header via Postman? list={item1,item2,item3}. This is not working while I want to test via Postman. Is there any way? Answer You can add the header this way In the headers tab,

How to return CREATED status (201 HTTP) in ResponseEntity

There is a Spring-MVC application. In controllers, when returning the results of methods, I return via ResponseEntity<>. On success, I return (200 statutes) the OK-method. But when creating something, I would like to return the CREATED-method (201 status). I just can’t understand what kind of URL to ask in parentheses when calling through CREATED. How can this be implemented? Now

Advertisement