score:1

Accepted answer

I have resolved this myself in the end using the following:

HttpClient client = new HttpClient();
        client.BaseAddress = new Uri("http://export.highcharts.com");
        client.DefaultRequestHeaders.Accept.Clear();
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
        var content = new StringContent(json, Encoding.UTF8, "application/json");

        HttpResponseMessage response = client.PostAsync("", content).Result;
        if (response.IsSuccessStatusCode)
        {
            FileStream fileStream = new FileStream(pathname, FileMode.Create, FileAccess.Write, FileShare.None);
            response.Content.CopyToAsync(fileStream).ContinueWith(
               (copyTask) =>
               {
                   fileStream.Close();
               });
        }
        else
        {
            Console.WriteLine($"Failed to poste data. Status code:{response.StatusCode}");
        }

The json for it I constructed via the options here: https://www.highcharts.com/docs/export-module/export-module-overview

Apologies for the crude example which I will obviously modify and clean up my end but wanted to give the answer to this should anyone else find it useful.


Related Query

More Query from same tag