C# is a general-purpose, multi-paradigm programming language. C# encompasses static typing, strong typing, lexically scoped, imperative, declarative, functional, generic, object-oriented, and component-oriented programming disciplines. This tutorial is how to check a file for malware using API in .NET C# programming language.
REPLACE_ME
with your API key.location
value in body with url location of your file.callback
value in body to your webhook url. We recommend using webhook.site as a callback url during test.For 2 and 3, you can find this documented at Offical Documentation
var client = new RestClient(new RestClientOptions("https://api.filescanapi.com")
{
MaxTimeout = -1
});
// Create a POST request to the asynchronous file endpoint
var request = new RestRequest("/v1/file/async", Method.Post)
.AddHeader("x-api-key", "REPLACE_ME")
.AddHeader("Content-Type", "application/json");
// Construct the JSON body using verbatim string literals for readability
var body = @"
{
""location"": ""https://filescanapi.com/icon.png"",
""metadata"": {
""filename"": ""demo.png""
},
""callback"": ""https://webhook.site/""
}";
// Add the JSON body to the request
request.AddStringBody(body, DataFormat.Json);
// Execute the request asynchronously and output the response content
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.filescanapi.com/v1/file/async");
request.Headers.Add("x-api-key", "REPLACE_ME");
var content = new StringContent(@"
{
""location"": ""https://filescanapi.com/icon.png"",
""metadata"": {
""filename"": ""demo.png""
},
""callback"": ""https://webhook.site/""
}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());