Skip to content

Instantly share code, notes, and snippets.

@pofider
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pofider/1897f8a1b6dab72a49b0 to your computer and use it in GitHub Desktop.
Save pofider/1897f8a1b6dab72a49b0 to your computer and use it in GitHub Desktop.
Render jsreport template from .net 4.0
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