216 questions
0
votes
1
answer
67
views
Spring boot 3.4.x OIDC2.0 - Try to ignore SSL validation, but not working and throws exception - DNS not matching
Trying create an Oauth 2.0 browser flow by using spring-boot 3.x (3.4.11) spring-framework 6.x application.
authorization_code has generated. Then "restTemplate" call to make the token is ...
0
votes
0
answers
149
views
Checkmarx issue(SSRF) on queryparam String
Our controller looks like this:
public ResponseEntity<ServiceResponse<List<String>>> getItemIdentifiers(
@RequestParam(required = true) String category_,
@...
2
votes
2
answers
4k
views
Spring Boot 3.4 new feature : How to config SSLBundle works with RestClient?
I am using Spring Boot 3.4.1 , JDK 23, MySQL 9. I am excited with new feature RestClient inside new Spring Framework version . I can done mutualTLS with RestTemplate without any concern, now I want ...
1
vote
0
answers
557
views
How to Resolve servletRequest cannot be null error for OAuth2 RestTemplate Interceptor in Spring Batch?
I'm trying to replace the deprecated OAuth2RestTemplate with a custom interceptor approach for adding an x-access-token header using the ClientHttpRequestInterceptor in Spring Batch. My goal is to ...
0
votes
0
answers
47
views
How can you build a URI in Java that has a path segment fully URL encoded?
I'm trying to call the GitLab Repository File API (https://docs.gitlab.com/ee/api/repository_files.html)
It states that the file path is part of the URL path and it should be url encoded.
When i try ...
1
vote
1
answer
436
views
Cant get TestRestTemplate to not follow redirects
I want to test some endpint that return a redirect (302).
I want to use TestRestTemplate to test it but I cant get it to not automatically follow the redirect. I just want to get the response not make ...
0
votes
2
answers
70
views
How to upload a big file by RestTemplate?
I get a MultipartFile from users and resent it to an API by RestTemplate. But I get ArrayIndexOutOfBoundsException if a file size biger than 2gb
java.lang.ArrayIndexOutOfBoundsException: arraycopy: ...
2
votes
0
answers
524
views
Migrating RestTemplate code to RestClient code in Spring Boot app
I want to use the Spring Boot's RestClient feature for my application.
So, I want to migrate the existing Spring Boot's RestTemplate code to Spring Boot's RestClient code.
I have a code that works ...
2
votes
1
answer
1k
views
WebClient micrometer trace propagation is not working
Spring boot version 3.3.2
When using WebClient with each request to another microservice new traceId is created:
api-gateway service -> order-service
same traceID for api gateway and order service
...
1
vote
2
answers
214
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
vote
0
answers
33
views
Translating RestTemplate to WebClient, PUT with empty Body
I have this code in Java 8 using RestTemplate.
@Override
public ResponseCambioEstadoDTO actualizarLead(String idLead) {
Map<String, String> uriVariables = new HashMap<>();
...
-1
votes
1
answer
31
views
spring resttemplate call throwing unauthorized error
i need to call service admin app to app with http. both the services is listening on port
c053b74b7e3a app-pre_prod:latest "java -jar -Dspring.…" 0.0.0.0:8080->8080/tcp, :::8080-&...
0
votes
1
answer
91
views
Internal server error in server works in localhost
Below code is throwing 500 Internal server error only in server but works in local host. Any input is appreciated.
Controller endpoint:
@ApiOperation(value = "This API gets info from external ...
1
vote
0
answers
220
views
How to handle HTTP 429 in Spring Boot AI App?
I am trying to develop a application using spring Gen AI.
Endpoint returns a Http 429 error code
Error response: I ran into this error below
retrofit2.adapter.rxjava2.HttpException: HTTP 429
at ...
2
votes
1
answer
3k
views
Server Side events consumer from spring boot
Given that i have this service-A with this endpoint which returns contentType(MediaType.TEXT_EVENT_STREAM)
@Bean
public RouterFunction<ServerResponse> notificationsRoute(CustomHandler ...
0
votes
1
answer
549
views
How to get the response of an API call using Rest Template when the response type is unknown
I have a requirement where I need to fetch the response of various company results. Each company will share a REST API with me (with all the details to invoke the API). I need to read a particular ...
1
vote
2
answers
790
views
Again with spring-boot-starter-parent (3.2.5) Rest-Template does not send content-Length
As discussed in Springboot 3.2.0 custom RestTemplate doesn't send Content-Length there was a problem regarding content-length with spring-boot 3.2.0.
As recommended in https://github.com/spring-...
0
votes
2
answers
299
views
I work with Spring Boot and REST template. I want to get the information of user connect
I work with Spring Boot and REST template. I want to get the information of user connect but I get the information just if I connect with admin account and not the author account. This is my code
...
1
vote
1
answer
77
views
Endpoint does not respond when I use conversion to an object
I created an endpoint to return an access token to my application. When I convert the json from the token to an object called user, postman keeps processing it and reports a timeout. No errors are ...
1
vote
0
answers
2k
views
Parameter specified as non-null is null: method okhttp3.Request$Builder.addHeader after Spring Boot 3.x
After Spring Boot 3.x version, an error is received when passing a null header to Resttemplate. Is there any way to overcome this situation?
Error:
java.lang.NullPointerException: Parameter specified ...
0
votes
0
answers
66
views
Disable Encoding Process on RestTemplate Springboot XML Request
Is it possible to disable encoding process when request XML with RestTemplate?
I need to send my value like this
ud=HELLOOOO YEYEYE🥺🥺©À¥¥didi🥺wawa©yayuÀ
ud=HELLOOOO YEYEYE🥺🥺&...
1
vote
0
answers
364
views
SpringBoot RestClient TraceId
I switched from RestTemplate to RestClient in my application and since switching I’m unable to get the same TraceId between services. Is anyone else having this same problem?
I tried updating ...
3
votes
0
answers
237
views
resttemplate does not retrieve the full data of a file from server
My project is using sping boot 2.3.3.RELEASE.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<...
-1
votes
1
answer
179
views
404 Bad Request error Spring Boot for Open Api
@Service
public class AirService {
@Value("${api.key}")
private String apiKey;
@Value("${api.url}")
private String apiUrl;
@Autowired
private ...
6
votes
2
answers
2k
views
Invalid proxy for apache httpclient5 with GET
I migrated to spring boot 3 and java 21.
Since I have a patch rest call to make, i needed the dependency org.apache.httpcomponents.client5:httpclient5:5.2.2.
But with that dependency, I get a "...
0
votes
0
answers
107
views
Not able to use mocked restTemplate twice
I am not able to use mocked restTemplate twice when calling an api with two different request bodies to have two corresponding responses, it’s giving suggestion like check the arguments for mocked ...
1
vote
2
answers
834
views
Handling special characters in uri
The below mentioned is my requestUrl
"http://localhost:80/v1/accounts/60a362bd6b84a37effc8f5a3/name/QA Analyst"
I am using the following code
UriComponentsBuilder builder = ...
-1
votes
1
answer
172
views
How to mock the RestTemplate getForObject
I am not able to mock below piece of restTemplate getForObject , Its giving assertion errors when i run my test case , can some one help me how to mock?.
ServiceClient.class
String localizationDetails ...
1
vote
1
answer
1k
views
Pooling RestTemplante setReadTimeout
I need to create a pool of connectors using apache.httpcomponents.client5:httpclient5:5.2.1* and SpringBoot(ver 3.1.5) RestTemplate.
This code works correctly:
private static RestTemplate ...
1
vote
1
answer
716
views
Connection reset when making a rest call with RestTemplate
I'm using
/* Apache HttpComponents */
val apacheHttpComponentsVersion = "5.2.1"
val apacheHttpComponentsGroup = "org.apache.httpcomponents.client5"
implementation(&...
1
vote
0
answers
681
views
Disable cookie management spring boot 3 RestTemplateBuilder
I am migrating from Spring Boot 2 -> Spring Boot 3
I had such method for getting the restTemplateBuilder to disable cookie management.
public static RestTemplateBuilder getRestTemplateBuilder() {
...
1
vote
0
answers
318
views
Handling OOM issue while sending 1GB Binary file using Spring RestTemplate
In my application we are reading more than 1 million rows from DB. Storing this data in Csv file in streaming manner by using Jdbc ResultSet. OpenCsv library is used to create CSV file which is zipped ...
0
votes
0
answers
52
views
Java Spring Framework Is there a way to only allow the application to make network requests to specific urls
I have a slightly strange use case where my application can run on two different types of networks one of which is extremely restricted and I have encountered issues where the application works on the ...
1
vote
2
answers
3k
views
micrometer - spring boot 3 - rest template - traceids are not propagated as expected
I have two spring boot services A and B.
Service A uses a RestTemplate to call an endpoint in Service B.
RestTemplate and the call in Service A looks like below:
@Bean
public RestTemplate ...
-1
votes
1
answer
213
views
Unable to call external api using spring boot
when I am trying to call external api using spring boot from public network it is giving response, but when I am calling in from private network then it is giving timeout exception
ResponseEntity<...
1
vote
0
answers
65
views
How do I enter the id manually, even though it is GenerationType.IDENTITY
I want to enter a manual id so I can test, but even if I enter 7 it creates the id
I want my entity to be auto incrementing, but if I enter the value manually I get the manual value, but even if I ...
1
vote
3
answers
2k
views
With Java HttpClient, how to handle responses other than 200 (SUCCESS)?
When using rest template we can handle response statuses other than 200 based on the exception thrown by resttemplate. This article describes this in detail.
By default, the RestTemplate will throw ...
1
vote
1
answer
984
views
How to return ResponseEntity when mocking RestTemplate
following is my method which I am trying to unit test
public class Emp {
public String getName() {
ResponseEntity<LinkedHashMap> res = restTemplate.postForEntity(url, null, LinkedHashMap....
1
vote
0
answers
556
views
RestTemplateBuilder setConnectTimeout not working
When I use auto-configured bean of RestTemplateBuilder, the timeout field doesn't set as intended.
code:
public WebHookService(RestTemplateBuilder restTemplateBuilder) {
restTemplate = ...
0
votes
1
answer
329
views
REST: openapi generation - response needs XML/JSON conversion while request is XML String
I'm building a client for an API where endpoint accepts XML for request (application/xml) and provides XML/JSON back in response (applicaiton/json, application/xml)
At the moment of calling the API I ...
0
votes
1
answer
1k
views
spring kotlin restTemplate - how to parse JSON array inside response
I keep struggling with parsing response represented by a JSON array into a data class entity using Spring with Kotlin and RestTemplate. Non-array like responses are without an issue, ie. the following ...
0
votes
1
answer
267
views
Java Spring RestTemplate getForObject response not decoded properly
I am trying to execute a HTTP GET request that I can execute properly in Postman in my Spring Boot application using the RestTemplate class.
This is the code I am using to send the request:
...
-1
votes
2
answers
613
views
My spring boot is of Microservice architecture. Getting 500 Internal Server between microservice calls using rest template
My spring boot is of Microservice architecture. Getting 500 Internal Server error logged in calling microservice.
Service A calls Service B with POST request. And Service B processed the request ...
0
votes
1
answer
6k
views
Cannot invoke"org.springframework.web.client.RestTemplate.getForEntity(String, java.lang.Class, Object[])""this.restTemplate"null [duplicate]
i'm working on an tokenValidationInterceptor , where a request for token validation is send to an other micro-service which communicate with keycloak and send an ok status or unautorazed status , then ...
3
votes
1
answer
3k
views
Preemptive Basic auth with Apache HttpClient 5.2
Is there a way to implement preemptive basic authentication with Apache HttpClient 5.2 using a HttpRequestInterceptor similar to how it's done here (accepted response) for Apache HttpClient 4?
We use ...
1
vote
2
answers
2k
views
How to call https url using spring boot 3
I try to configure restTemplate to call https url in spring boot 3 but that does not compile. For this i use import org.apache.http.impl.client.HttpClients import org.apache.http.ssl.SSLContexts and ...
1
vote
2
answers
1k
views
Logging both ClientHttpRequestInterceptor and HttpServletRequest (or HandlerInterceptor)
I'm developing an API using Spring Boot 3.1.0 to crawl data, I called this localhost:8080/crawl. Inside this, I also use RestTemplate to call an external API called third-party.com/data.
I want to ...
0
votes
0
answers
4k
views
Getting RestTemplate (Connection Reset) Despite everything is correct
I'm using Spring Boot RestTemplate to call REST API.
On PROD, I'm getting below exception:
org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://<host&...
0
votes
1
answer
1k
views
Call to GraphQL Query with RestTemplate is giving either 400 or invalid syntax message
I have been experiencing a weird issue trying to call a GraphQL query using RestTemplate from the SpringBoot framework. I say it is weird because it is only happening with this particular query.
This ...
2
votes
1
answer
2k
views
How to implement test to check that actuator metrics are exist ? 404 for /actuator/prometheus in tests
I have a spring boot appication(version is 3.0.4):
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
&...