Posts

Post not yet marked as solved
0 Replies
131 Views
I'm developing a REST API app that generates some PDFs for my users, but there are only available for a certain period of time. To download them I'm using the a HTML tag: <a href="/api/items/1/generate?type=register" download="Important Letter.pdf"> <svg>...</svg> </a> This works fine in the normal flow of the use case, but if a user request a PDF outside of the download period, the server responds to the request with a 422 (Unprocessable Entity) HTML code, and place a json on the body of the request: HTTP/1.1 422 Unprocessable Entity Content-Type: application/json;charset=utf-8 {"error" : "Registration period expired", "type" : "expired", "data" : {"id" : 1}} Safari does not interpret this error and it generates the Important Letter.pdf file and writes the json content on it. Is there a wat to avoid this behavior and display an error message to the user? I was wondering if my server should send some specific error code.
Posted
by soyPabloG.
Last updated
.