Skip to content

RestClient uri builder path , queryparam , pathsegement not building properly error showing " Target host is not specified " #45340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pavan1289 opened this issue Apr 30, 2025 · 2 comments
Labels
status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged

Comments

@pavan1289
Copy link

pavan1289 commented Apr 30, 2025

Bean created :

@Bean("restCustomClient")
RestClient client = RestClient.builder()
    .baseUrl("https://api.example.com/ars")
    .build();

Autowired in our service or component class :

@Autowired 
@Qualifier("restCustomClient")
RestClient restCustomClient


restCustomClient.get()
    .uri(uriBuilder -> uriBuilder.path("/endpoint").build())
    .retrieve()
    .body(String.class);

​In Spring Boot 6.2, the normalize() after constructing inside URI builder as well showing always

Error Message :

It sounds like you're encountering the message: "Target host is not specified."

URL not able to construct after providing the all the query-param and path segment automatically add "/" internally each path separation tried all the possibilities.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 30, 2025
@wilkinsona
Copy link
Member

Given that you're creating RestClient yourself, Spring Boot isn't involved in its creation and configuration. You've also mentioned query parameters in your description, but I can't see any use of them in the snippet of code that you've shared. In short, it's not clear that this is a Spring Boot problem and I do not yet understand how to reproduce it.

If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Apr 30, 2025
@spring-projects-issues
Copy link
Collaborator

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

3 participants