3

I have an endpoint as:

@Path("/products")

    @Produces({ MediaType.APPLICATION_JSON })
    public interface Products {

        @PUT
        @Path("/{productId}")
        ....
    }

I have a jax-rs client implemented for this service and have it imported in the another service that I am calling this from.

So I am calling the client as below from my second service

public String updateProduct(String productId){
..
  return client.target(this.getBaseUrl()).path("products/").path(productId).request(MediaType.APPLICATION_JSON_TYPE).put(Entity.json(""), String.class);
}

If I have a product with slashes say "control/register app" , the service does not seem to take it well. I did encode the productId before making a call to the service and then decoded it once received. But that doesnt seem to work and I get a 404 not found. Any ideas? Thanks in advance

San Kay
  • 91
  • 2
  • 8
  • Possible duplicate of [@PathVariable in SpringBoot with slashes in URL](http://stackoverflow.com/questions/43470421/pathvariable-in-springboot-with-slashes-in-url) – P.J.Meisch May 15 '17 at 18:03
  • 2
    @P.J.Meisch It's not a duplicate of the above mentioned question, once the OP is using JAX-RS instead of Spring MVC for the REST API. – cassiomolin May 15 '17 at 19:58

1 Answers1

7

Using @Path("{productId : .+}") should work.

cassiomolin
  • 124,154
  • 35
  • 280
  • 359