static void Main(string[] args) { Reporterinfo repinfo = new Reporterinfo { discloseEmail = "TRUE", reporterEmail = "*****@*****.**", reporterName = "You", reporterNotes = "This is a code sample test", reporterOrg = "YourOrganization", reporterPhone = "555-555-5555" }; Threat1 threat1 = new Threat1() { threatType = "Activity", threatSubType = "INTRUSION_ATTEMPT", sampleType = "Base64", sourceIp = "1.1.1.1", destinationIp = "2.2.2.2", sourcePort = "22", destinationPort = "1433", protocol = "foo", byteCount = "600", packetCount = "20", date = DateTime.Now.ToString("yyyy-MM-dd"), time = DateTime.Now.ToString("hh:mm:ss"), timeZone = "-00:00", sample = "null", sourceUrl = "attacking url", destinationUrl = "attacked url" }; Threat threat = new Threat() { threat = threat1 }; Threat[] t = new Threat[] { threat }; Report1 rep1 = new Report1 { disclosureNotes = "This is a test from example code on Git", reportNotes = "This is a test from example code on Git", TLP = "White", threats = t }; Report rep = new Report { report = rep1 }; Report[] r = new Report[] { rep }; CERTReport cert = new CERTReport { reporterInfo = repinfo, reports = r }; MakeRequest(cert).GetAwaiter().GetResult(); }
static async Task MakeRequest(CERTReport cert) { var client = new HttpClient(); var queryString = HttpUtility.ParseQueryString(string.Empty); // Request headers client.DefaultRequestHeaders.Add("api-key", "{your api-key}"); var uri = "https://api.msrc.microsoft.com/engage/cars?" + queryString; HttpResponseMessage response; // Request body string str = JsonConvert.SerializeObject(cert); //NewtonSoft serializes the object.toString() to JSON using (var content = new StringContent(str)) { content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); response = await client.PostAsync(uri, content); } }