Closed drenda closed 2 years ago
This is a known limitation in the Angular HttpClient. See #166. You cannot specify to accept a blob for status code 200 and json for others, for example. So you should parse the blob yourself in this case in order to extract the corresponding object.
@luisfpg I'm not sure I understand.
In the case of the 200, depending on the Accept header, the server should be able to return either a PDF, or a JSON right ? (let's put exceptions aside for now, just focus on a valid request/response with 200 status).
Shouldn't it be able to generate two methods in the client. One for the PDF and another one for the JSON ?
In this case, of having 2 different content types, 2 different methods will be generated. The OP was about different response types (json vs blob).
I've an endpoint like this, used to download a PDF report. This endpoint could thrown an error that is returned as a JSON model. In fact in the declaration it's set we can receive either a PDF or a JSON.
But the implementation is like this:
where you can see the http.request accept just an application/pdf, so when there is an excpetion, the server is not able to serve the client because the accept doesn't permit to reply back with a JSON content.
Is this a bug or a know limit of the library? Is there any workaround for this that doesn't imply to modify manually the generated service?
Thanks