How to Virus Scan Files in SharePoint Online Site Drive with JavaScript

Cloudmersive
2 min readMay 18, 2022

Detecting tainted files in storage is crucial for keeping your SharePoint Online Site Drive safe from viruses and malware.

Thankfully, there’s a Cloudmersive API for that. Our Virus Scanning API contains an iteration specifically designed to accompany your Site Drive instance, and once configured it’ll check each new file for viruses, malware, trojans, ransomware, spyware and more, leveraging over 17 million stored signatures.

At the bottom of this article, we’ve provided instructions to help structure your API call with JavaScript. To take advantage of this API, however, you’ll also need a ClientID & clientSecret, with are attainable by following instructions on the Cloudmersive API Console under the POST /virus/scan/cloud-storage/sharepoint-online/site/single dropdown.

To install the jQuery library, run the following command:

bower install jquery

After that, include the below code to structure your API call. Note that you’ll need to include your SharePoint Domain Name, SiteID, and the File Path:

var settings = {
"url": "https://api.cloudmersive.com/virus/scan/cloud-storage/sharepoint-online/site/single",
"method": "POST",
"timeout": 0,
"headers": {
"clientID": "<string>",
"clientSecret": "<string>",
"sharepointDomainName": "<string>",
"siteID": "<string>",
"tenantID": "<string>",
"filePath": "<string>",
"itemID": "<string>",
"Apikey": "YOUR-API-KEY-HERE"
},
};
$.ajax(settings).done(function (response) {
console.log(response);
});

All done. Once configured, you’ll have added a big boost to your SharePoint threat profile, ensuring sneaky malicious files don’t sit dormant in storage.

--

--

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.