0

I am using Consul for Service Discovery. Have a service called core-service where there is an API, which accepts a Path Variable, as -

@GetMapping("/records/status/{status}")

I need to discovery this API using DiscoveryClient.

My code is:

URI uri = discoveryClient.getInstances("core-service").stream().map(si -> si.getUri()).findFirst()
                .map(s -> s.resolve("/records/status/" + status)).get();

But I am receiving 404 Not found error. Pls guide.

ekansh
  • 716
  • 8
  • 16
  • You are mapping to `/records/your-status` but are sending a request to `/records/status/your-status`. The URLs are different which obviously will lead to a 404. Either your mapping is wrong (should be `/records/status/{status}` or your client is wrong and should send to `"/records/" + status`. – M. Deinum Sep 07 '20 at 08:46
  • Sorry, My API which I want to discover is: records/status/{status}. Have made the edit. – ekansh Sep 07 '20 at 08:48
  • Please add the stack trace and/or error you get. What is leading to the 404? The discovery of the service or making the actual request. – M. Deinum Sep 07 '20 at 09:27

0 Answers0