-
Notifications
You must be signed in to change notification settings - Fork 14
/
C#Code.cs
52 lines (39 loc) · 1.11 KB
/
C#Code.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Threading.Tasks;
using System.Web;
using System.Net.Http;
using System.Net.Http.Headers;
using Newtonsoft.Json;
namespace CARSexample
{
class Program
{
static void Main(string[] args)
{
CERTReport cert = new CERTReport
{
// Data model documentation at https://msrc.microsoft.com/report/developer
};
MakeRequest(cert).GetAwaiter().GetResult();
}
static async Task MakeRequest(CERTReport cert)
{
var client = new HttpClient();
var queryString = HttpUtility.ParseQueryString(string.Empty);
var uri = "https://api.msrc.microsoft.com/report/v2.0/abuse";
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);
}
}
}
//This is the JSON body converted to C#
public class CERTReport
{
// Data model documentation at https://msrc.microsoft.com/report/developer
}
}