Last active
August 29, 2015 14:14
-
-
Save pofider/1897f8a1b6dab72a49b0 to your computer and use it in GitHub Desktop.
Render jsreport template from .net 4.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://localhost:4000/api/report"); | |
myRequest.Method = "POST"; | |
myRequest.ContentType = "application/json"; | |
var dataString = JsonConvert.SerializeObject(new | |
{ | |
template = new | |
{ | |
shortid = "bk_Ctaj-q" | |
} | |
}); | |
var data = Encoding.ASCII.GetBytes(dataString); | |
myRequest.ContentLength = data.Length; | |
Stream newStream = myRequest.GetRequestStream(); | |
newStream.Write(data, 0, data.Length); | |
newStream.Close(); | |
var response = myRequest.GetResponse(); | |
var responseStream = response.GetResponseStream(); | |
using (var file = File.OpenWrite("out.pdf")) | |
{ | |
responseStream.CopyTo(file); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment