I have a C# API which is currently used by a number of our websites. My API is sent a JSON request, I do some stuff based on the details in that request, then send a JSON response with the outcome of the API's work, and some other information.
I now need to do include some extra information in my JSON response.
I need to read a file in from a specific Url (this file may be an image, a MS word doc, a PDF etc. - could be anything really).
I already know the mime type of this file at the url (so as to determine whether it's valid for me to process or not).
If it's a supported file/mime type, I want to retrieve this file from the specified url and ultimately convert it/serialize it to JSON and include it within my JSON response.
In some cases, I may actually have multiple files/urls that I need to retrieve, convert and include within my JSON response (ideally as an array, inside a property called 'Attachments').
I've used Newtonsoft.Json for serializing and deserializing classes with regular properties before, but not done anything with reading in files and sending them as JSON, and can't find any clear examples of how to go about this.