Questions tagged [spring-rest]
Use this tag for question about the REST architectural style used in Spring framework
1,268
questions
0
votes
0
answers
15
views
FeignException.FeignClientException Junit Test Method
I am looking help to write junit test method for FeignException.FeignClientException
try {
responseBody = oktaClient.createUser(oktaUser).getBody();
} catch (FeignException....
1
vote
0
answers
30
views
Spring 400 Bad Request When Sending Multipart Request
I am attempting to call from Service Consumer (Project 1) to Service Provider (Project 2) with Multipart data using spring REST service, but I am receiving 400 bad request error. Both the services are ...
0
votes
1
answer
42
views
Best design with fault tolerant for retrieving updates periodically invoking an API
I am a client say clientA, I will need to call a server say serverA in a periodic manner every 15 minutes to get new updates from serverA.
ServerA is only capable to expose an API which intakes 2 ...
-2
votes
1
answer
23
views
REST API object conversion in java
I have request body of supplier in below format :
{
"supplier": {
"supplierData": {
"supplierAddress": {
"street": "abc",
&...
1
vote
2
answers
33
views
RequestBody and camel case request parameters
I have an endpoint with a request body:
@PostMapping("/v1/message")
@PreAuthorize("#oauth2.isAnyClientId(@authorizeConfig.getIds())")
public void receive(
@RequestBody @...
0
votes
0
answers
37
views
Issue with saving entities with associations (ManyToMany) while using REST API
I have a Spring REST application. The application has few entities like Question, PossibleAnswer.
These entities are as follows:
Question.java
public class Question {
@Id
@...
0
votes
0
answers
49
views
RestTemplate exchange - getting empty response body incase of 403 error
I have 2 spring boot applications with Rest APIs and I'm running it locally for testing. I'm using Rest Template to connect from one service to the second service and getting the response data and ...
1
vote
1
answer
110
views
How do I post nested entity to Spring Data Rest without setting @RestResource(exported = false)?
I've read this answer as a solution to POSTing an entity with nested entities. But I want to make a RESTful POST request.
That is, I want nested entities to be represented with links.
As an example, ...
0
votes
0
answers
45
views
How to create an EntityModel for type with nested resources using Spring HATEOAS?
I have an address entity model, EntityModel<Address>:
{
"id" : 10662,
"streetNumber" : 4823,
"steetName" : "Bakersfield",
"city" : &...
0
votes
1
answer
35
views
Spring Data Rest and Rest Controller together
I'm using Spring Data Rest and have @RepositoryRestResource defined with the path is "pathXYZ". Now I have a class with @RestController and defined a @GetMapping with "pathXYZ/custom&...
0
votes
0
answers
31
views
Spring Boot doesn't recognise Multipart parameter throwing MissingServletRequestParameterException
I'm using a custom Multipart Resovler for accepting a large file size for one end point and all others have default max-file-size set in application.properties.
public class CustomMultipartResolver ...
0
votes
1
answer
46
views
Send Restful API JSON response from Spring Boot Filter
I am using following filter for checking if a specific HTTP Header is present on api request.
@Component
@RequiredArgsConstructor
public class HeaderValidationFilter extends OncePerRequestFilter {
...
1
vote
0
answers
23
views
Could not set field value [] value by reflection after creating a rest controller
I'm calling save method of hibernate from a rest controller using service layer
rest controller -> service layer -> repository layer //not working
main(a temporary class to check service layer) /...
0
votes
0
answers
83
views
Content type 'application/json;charset=UTF-8' not supported with spring boot application
I am using spring boot application. The application has one POST endpoint. There are many bidirectional entities in the application.
I tried to save the Questionnaire (one of the entity ) I get the ...
0
votes
0
answers
66
views
The origin server did not find a current representation for the target resource in Spring rest project and mongodb
I have an issue with my project with a rest app running on tomcat 9, if I type any request for example http://localhost:8080/appmvc/service/hello or http://localhost:8080/appmvc/service/list the ...
0
votes
2
answers
121
views
java.io.IOException: Async IO operation failed (1), reason: RC: 32 Broken pipe
I am getting given below error in application log, even though request processing completed successfully ie Producer process the request successfully .
Caused by: java.io.IOException: Async IO ...
0
votes
0
answers
23
views
how to handle stream api from other service data in my spring boot service
there is a service that will stream the data.
Please Help ->
how to implement the handler that waits until all the data is received?
0
votes
0
answers
12
views
Spring: NullPointerException when calling FeignClient [duplicate]
when I want to call the method of my Spring FeignClient I get a NullPointerException:
FeignClient
@FeignClient(url="http://localhost:8080", name="feignClient")
public interface ...
2
votes
0
answers
117
views
Allow only GET and POST HTTP methods for "*" target in Spring Web application
this question is the continuation of Restrict HTTP methods (only GET and POST) in Spring Web application: the original question was not correct because of a bad understanding of the client request
A ...
0
votes
2
answers
65
views
Spring REST any way to set the JSON type field automatically?
I'm using Spring 5.3.20 to build a REST/JSON API, which is based on automatic mapping of Java POJOs to JSON objects. For instance:
@RestController
@RequestMapping ( path = "/{ds}/dataset-info&...
1
vote
2
answers
164
views
Restrict HTTP methods (only GET and POST) in Spring Web application
For security purpose regarding my Springboot application, one client is asking for a restriction of the allowed methods
Indeed, although my application only provides GET and POST methods, when I run ...
0
votes
1
answer
189
views
Spring boot rest requestbody and @valid not working when object is null/empty
I am trying to apply not null validation on an attribute of my request which is instructedAmount but it is not working. I have a Spring Boot (V2.3.0.RELEASE) application with the following endpoints:
@...
0
votes
1
answer
67
views
Spring 5: use RestTemplate to POST multiple files with POJO; MediaType.MULTIPART_FORM_DATA with LinkedMultiValueMap
Versions:
Java 11
Spring 5.3.9
Jackson 2.13
org.apache.httpcomponents:httpclient: 4.5.13
I believe the issue here is that out-of-the-box, RestTemplate cannot deal with an HttpEntity for which the ...
0
votes
0
answers
12
views
Field departmentrepositoryy in service.DepartementServiceimpl required a bean of type 'repository.DepartmentRepository' that could not be found
entity
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class Department {
public ...
-1
votes
1
answer
16
views
Does writing each rest api in it's own specific java file will help in performance boost even though they have the same base path
For example, I have two rest APIs with the same base path.
First REST API
api1.java -> Annotated with @RestController
@RestController("/basepath")
public class Api1 {
@GetMapping(&...
0
votes
2
answers
76
views
Should using Traverson for consuming Spring HATEOAS HAL response result in duplicate invocations of the service?
I have a REST endpoint (like http://myapi.rest.com/someEndpoint?offset=40&limit=20) that vends out HAL JSON response like the following
{
"_embedded": {
"listOfObjects&...
0
votes
1
answer
50
views
How can I implement frontend in API without using a framework?
hope you are having a great day.
I will get straight to the point, I have an application in Spring. I am using API calls from postman to retrieve my data.
Now I am asked to implement a front-end but ...
1
vote
1
answer
92
views
Can one Queue Deliver messages to multiple Consumer In fanout exchange?
I want to know do we need to create three different queues to deliver message to three different consumer? Like here I have created 3 queues and bind it to the fanout exchange and then I in publisher ...
0
votes
1
answer
19
views
Generate Asciidoc files with custom visual style
I managed to generate asciidoc files with the generic ui style.
Is it possible to change the default ui style to this ui style: https://docs.spring.io/spring-framework/docs/current/reference/html/
0
votes
0
answers
49
views
How to get value in another table when I want POST Object in Spring REST
I have two Entity:
@Entity
public class Family {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String familyName;
private Integer ...
0
votes
0
answers
166
views
Spring Security Requests are 403
I am currently working on an application with spring, and I currently face the problem that all requests I do return the error 403 - Forbidden. It is not only [post,put,patch,delete], but also get. ...
0
votes
1
answer
208
views
How can I return validation errors in a RFC-7807 format in Spring Boot Data Rest controllers?
I have a Spring repository
@RepositoryRestResource
public interface MongoIntegrationTokenRepository extends MongoRepository<IntegrationToken, String>, CrudRepository<IntegrationToken, String&...
0
votes
1
answer
49
views
Super CSV (org.supercsv.io) invalid content length on Spring REST controller: ERR_CONTENT_LENGTH_MISMATCH 200
Im using Super CSV to provide REST endpoint with some data. It was working fine for a long time, but now data is too large and half of it is not delivered by Spring REST Controller. I have to set ...
1
vote
0
answers
167
views
Exception not getting captured when @Transactional (Rollback = Exception. Class)
I'm facing an issue while using Exception handling(try/catch) along with @Transactional(Rollback = Exception. Class).
The customized exception message doesn't show up , only the rollback message will ...
0
votes
0
answers
45
views
Using TestRestTemplate to test a OncePerRequestFilter in integration test
My OncePerRequestFilter class structure is as follows :
@Component
Class FilterA extends OncePerRequestFilter{
@Override
protected void doFilterInternal(HttpServletRequest req, HttpServletResponse ...
0
votes
0
answers
10
views
Spring not rendering nested object while using HAL+JSON
I'm currently using the default Spring REST HAL+JSON since my repositories extend JpaRepository, but I'd like a deeper object graph to be rendered without having to perform multiple http requests.
I ...
0
votes
1
answer
314
views
Spring boot RestTemplate upload file to SharePoint online but file is corrupted
There is a RestController and I try to upload a MultiPartFile to SharePointOnline using, the SharePoint REST API I'm also using proxy due to corporate restrictions.
@Override
public ResponseEntity ...
0
votes
0
answers
136
views
Spring Rest exception handler get request name and value on error
I have a spring boot (version:2.3.0.RELEASE) application and Rest API is defined as follows:
@PostMapping(value = "/output/p1")
public ResponseEntity<PaymentResponse> ...
0
votes
2
answers
264
views
What is DDD's Aggregate in SpringBoot MVC?
Suppose I've a bunch of microservices, each written on SpringBoot MVC (REST, Controller, Service, etc..)
Can anybody explain what is DDD's Aggregate in SpringBoot MVC? is it a controller? Or is it a ...
0
votes
2
answers
111
views
Spring RestController catch all RequestMapping and continue to the correct endpoint
Say I have a @RestController like below:
@RestController
@RequestMapping("/1st")
public class MyController {
@GetMapping("/2nd/aaa")
public void getAaa() {
...
}...
0
votes
1
answer
354
views
How to connect to local running server in springboot testing
My application is running in local with port 8089, I am trying to do Spring Rest Controller testing.
It is running in 8089 port.
In application.yml
spring:
profiles:
active: sit
In application-...
0
votes
1
answer
47
views
Spring rest-service: PUT Method returning HTTP 400
I have the following rest service api to update a "friends" dataset:
@PutMapping("/{id}")
public ResponseEntity<Friends> updateFriendship(@PathVariable("id") ...
0
votes
0
answers
48
views
AssertionError: expected:<8089> but was:<-1>
My application is running in local, I am trying to do Spring Rest Controller testing.
It is running in 8089 port.
In application.yml
spring:
profiles:
active: sit
In application-sit.yml
server:
...
-1
votes
1
answer
375
views
Why spring boot didn't save my sessions and cookies between requests?
Spring boot doesn't save sessions between requests. I have to methods: /login and another one is /getInfo. They're placed in different controllers. DB for sessions is MongoDB and I can see through ...
1
vote
0
answers
133
views
Return list of Errors using ResponseEntity
Trying to send list of Error in response, but in response getting only one parameter of Error type
Public class Error {
private ErrorEnum errorCode;
private String errorDesc;
}
Error response ...
0
votes
0
answers
141
views
Redis Server is not getting Refreshed
I'm using redis in my springboot rest application to store cache. But the problem I'm facing is once it is stored in redis my api only hits the redis not the database. I've added time out property it ...
0
votes
1
answer
109
views
Migrated Spring boot 1.5.x t0 2.3.x and one endpoint not working
I have migrated spring boot 1.5 to 2.3 every thing is working except 1 endpoint that is returning error : "org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 :"...
0
votes
1
answer
361
views
Why can not persist data in spring data jpa
While save data in database got exception Cannot handle managed/back reference 'defaultReference': back reference type not compatible with managed type. I got exception while persist data. I think ...
0
votes
0
answers
74
views
Exposing domain model in GRPC IDL
We have our existing domain model consumed using spring REST. The services are currently hosted on Kuberenetes and all east-west and north-south communication is done using http/1.1. We are planning ...
0
votes
0
answers
458
views
Convert String to Sort with in Spring REST RequestParam
I want to do a custom Page and Pageable class because I am not really satisfied with the JSON got from these Spring classes. For that, I have two POJO with a converter function to Pageable to use ...