Objective: Want to download a PDF file from the server by generating the below URL: http://localhost:4200/bookStore/secured/rest/books/14119
The URL gets generated when the below line gets executed in the book.js in routes.
return this.store.findRecord('book', bookId);
But I get 403 forbidden error. The error in details:
Error: Ember Data Request GET /bookStore/secured/rest/books/14119 returned a 403
Payload (Empty Content-Type)
Forbidden
at new AdapterError (-private.js:3170)
at Class.handleResponse (rest.js:594)
at ajaxError (rest.js:956)
at Class.hash.error (rest.js:623)
at fire (jquery.js:3317)
at Object.fireWith [as rejectWith] (jquery.js:3447)
at done (jquery.js:9274)
at XMLHttpRequest.<anonymous> (jquery.js:9514)
Do I need to set the content-type as 'application/pdf'? and if yes, then please suggest how to set it.
Below is the JS code:
routes\book.js
actions: {
pdfClick(bookId) {
return this.store.findRecord('book', bookId);
}
}
template\book.hbs
<button >PDF</button>
In the server side, the code which receive and respond the request is as follows:
@GET
@Path("/{bookId}")
@Produces("application/pdf")
public Response bookExport(@PathParam("bookId") long bookId) {
//Code
}
According to the server side code, we are getting PDF file from the server. This is tested successfully using PostMan.
Aucun commentaire:
Enregistrer un commentaire