0
@GetMapping(path = "/api/v1/{id}/{status}")  *** Line -1 
public String getEmployeeStatus(@PathVariable(value = "id") String id,
            @PathVariable(value = "status") String status)
{
   // here i want to call other REST API. But i want to pass path variables like {id} and {status} to the consuming API/Client URL.
        String clientURL=  "/api/employees/v1/{id}/employee/{status}"
        String name = "abc";
        String password = "bac";
        String authString = name + ":" + password;
        String authStringEnc = new String(Base64.getEncoder().encode(authString.getBytes()));
        String authorizationHeader = "Basic " + authStringEnc;
        Client restClient = Client.create();
        WebResource webResource = restClient.resource(clientURL);  *** line 14

        ClientResponse resp = webResource.accept("application/json").header("Authorization", "Basic " + authStringEnc).get(ClientResponse.class);

}

@line -14, i want to pass {id}, {status} to the client URL from my GET API(line 1). i dont know how to pass these values to the consuming api.

how to add even if i get clientURL from properties file.

1
  • What is that Client type you are using? Commented Apr 22, 2022 at 13:57

1 Answer 1

1

How about building your target URL as follows:

String clientURL=  String.format("/api/employees/v1/%s/employee/%s", id, status);
Sign up to request clarification or add additional context in comments.

2 Comments

very simple and I tried its working :) thank you @cloooze
don't know why my answer got downvoted, it solved the user's problem :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.