Reputation: 547
I got this ajax call :
var request = $.ajax({
type : "GET",
url : "/services/ged/download?pIdDocument=" + idDocument
});
idDocument
has this kind of value : {3F15D23C-1E9F-678B-B865-654E5866959F}
Here's le server side rest service :
@Path("/ged")
@RequestScoped
public class GedRest {
@GET
@Path("/download/{pIdDocument}")
@Produces("application/pdf")
public Response downloadPdfFile(@Context HttpServletRequest pRequest, @PathParam("pIdDocument") String pIdDocument) throws AInternalException {
// Get a pdf document
}
}
I got a http 500 on the browser, and here is the server side log :
com.sun.jersey.api.NotFoundException: null for uri: http://localhost:7003/services/ged/download?pIdDocument=%7B0F90D68C-3E9F-472B-B8F5-658E5816919F%7D
I tried to replace - by %2D that's the same:
com.sun.jersey.api.NotFoundException: null for uri: http://localhost:7003/services/ged/download?pIdDocument=%7B0F90D68C%2D3E9F%2D472B%2DB8F5%2D658E5816919F%7D
Any idea?
Upvotes: 0
Views: 62
Reputation: 4305
Looks like when you are defining the route you are assigning the pIdDocument to be part of the URI and not as a GET variable.
Try this as the url in your AJAX call:
"/services/ged/download/" + idDocument
Upvotes: 1
Reputation: 4453
What you need to do is
var request = $.ajax({
type : "GET",
url : "services/ged/download?pIdDocument=" + idDocument
});
Notice that I removed the starting /
from the URl.
When a URL starts from /
, it is considered from the root directory, which is NOT desired.
Remove the starting /
from the URL and it will act as a relative URL.
Upvotes: 1