So I have been fiddling around with Web responses and requests in C# and I received a problem when I tried to run the program. One of the lines of code I had:
var response = await httpClient.SendAsync(request);
required async in the method making
private static void Main(string[] args)
into
private static async Task Main(string[] args)
It looks like there is no error, but on build, I got the error message:
Program does not contain a static 'Main' method suitable for an entry point.
Here is my code
private static async Task Main(string[] args)
{
try
{
/*HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://billing.roblox.com/v1/gamecard/redeem");
request.Method = "POST";
request.ContentType = "application/json";
request.Accept = "application/json";
JsonExtensionDataAttribute data = new JsonExtensionDataAttribute();
data = '3335996838'*/
using (var httpClient = new HttpClient())
{
using (var request = new HttpRequestMessage(new HttpMethod("POST"), "https://billing.roblox.com/v1/gamecard/redeem"))
{
request.Headers.TryAddWithoutValidation("Accept", "application/json");
request.Content = new StringContent("3335996838", Encoding.UTF8, "application/json");
var response = await httpClient.SendAsync(request);
Console.WriteLine(request.Content);
Console.ReadLine();
}
}
}
catch (WebException ex)
{
string content;
using (StreamReader reader = new StreamReader(ex.Response.GetResponseStream()))
{
content = reader.ReadToEnd();
Console.WriteLine(content);
Console.ReadLine();
}
}
}
Someone please help me!