Is there a way to send back a file (.pdf) and JSON data in the body for a POST WebAPI request in .NET ?
Asked
Active
Viewed 743 times
2 Answers
0
You can convert the PDF file to a base64 string, and put it in the JSON. To convert a PDF into a base64 string in JS, start here. To convert back to the file in .Net, use Convert.FromBase64String.
-
1Possible but not recommended. The normal way is to return a json which also contains an url to the fat data. It should be up to the consumer when to get that huge amount of data – Sir Rufo May 13 '17 at 08:40
0
If the JSON is not very big, then you could return the PDF document normally and the JSON in a HTTP header like some metadata. Maybe this is not best practice, but could work.

Dávid Molnár
- 10,673
- 7
- 30
- 55