async Task Main()
{
string outputfile = "output.csv";
File.Delete (outputfile);
var httpWebRequest = (HttpWebRequest)WebRequest.Create(URL);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
string json = new JavaScriptSerializer().Serialize(new
{
startDate = "7/1/2018",
endDate = "6/30/2019",
codes = new string[] { "value1", "value2" },
skus= "",
returnCSV = 1
});
streamWriter.Write(json);
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
using (StreamWriter sw = new StreamWriter(outputfile))
sw.Write(await streamReader.ReadToEndAsync());
}
}
{
string outputfile = "output.csv";
File.Delete (outputfile);
var httpWebRequest = (HttpWebRequest)WebRequest.Create(URL);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
string json = new JavaScriptSerializer().Serialize(new
{
startDate = "7/1/2018",
endDate = "6/30/2019",
codes = new string[] { "value1", "value2" },
skus= "",
returnCSV = 1
});
streamWriter.Write(json);
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
using (StreamWriter sw = new StreamWriter(outputfile))
sw.Write(await streamReader.ReadToEndAsync());
}
}
No comments:
Post a Comment