microsoft / typed-rest-client

Node Rest and Http Clients with typings for use with TypeScript
Other
675 stars 118 forks source link

Adding support for text/plain content type responses #161

Closed emtencza closed 5 years ago

emtencza commented 5 years ago

Currently, the RestClient only accepts json/application content type responses, and will return null for text/plain content type responses. This change will set the response result to the raw content if JSON parsing fails (eg contents are not a JSON). This will allow for text/plain content type responses.

bryanmacfarlane commented 5 years ago

The typed-rest-client has two layers - rest client which turns a request into a resourceful json object and the http client which is used for raw http requests. If you're making a request that doesn't return and restful resource object (and instead a file stream, raw string contents etc...) then you should use the http client.

What's the scenario / issue where this is needed and the http client is not suitable?

emtencza commented 5 years ago

The http client works well for my scenario. I was trying to get the MIME content of an Outlook message using the rest client. I have switched it to the http client and it works. Thank you and I will abandon this PR.