Reputation: 4605
I have a table with fully qualified domain names as the primary key. I am setting up a REST api to manage the db (mainly inserts and deletes), but I have run into a problem sending an http DELETE request with a url as a path parameter.
Example:
REST api servlet container = http://www.someapp.com/api
Member resource id to be deleted = www.anotherapp.com/home
I want to send an http DELETE request to http://www.someapp.com/api/www.anotherapp.com/home
The Jersey resource path is:
@DELETE
@Path("/{url}")
public void deleteUrl(@HeaderParam("request-origin") String origin,
@PathParam("url") String url){
// some stuff
}
When I try this I get a 404 error. How can I send a FQDN as resource id in http DELETE method?
Upvotes: 1
Views: 233
Reputation: 4605
As bmargulies mentions in the comments, the error was caused by unescaped /
characters in the path parameter. The solution that worked for me was to add a regex to the @Path
annotation in Jersey.
@DELETE
@Path("/{url : .+}")
public void deleteUrl(@HeaderParam("request-origin") String origin,
@PathParam("url") String url){
// some stuff
}
Upvotes: 2