`SwagScanApi api = new SwagScanApi();
SwagClient client = api.getClient();
// Configure API key authorization: Apikey
ApiKeyAuth Apikey = (ApiKeyAuth) client.getAuthentication('Apikey');
Apikey.setApiKey('YOUR API KEY');
Map params = new Map{
'inputFile' => Blob.valueOf('Sample text file\nContents')
};
try {
// cross your fingers
SwagVirusScanResult result = api.scanFile(params);
System.debug(result);
} catch (Swagger.ApiException e) {
// ...handle your exceptions
}`
This gives error because Map is supposed to be declared as Map<string,Object). We fixed that.
Then get error that 'Invalid type: ApiKeyAuth'. We fixed that by using 'Swagger.ApiKeyAuth'
Then get the error "System.CalloutException: no protocol: "callout:virusapi/virus/scan/file"" - which makes sense because in swagger.invoke(...) it is hardcoding the endpoint to the above ("callout:virusapi/virus/scan/file") (in methods toPath and to Endpoint) - need to remove the extra double quotes in the start and end
Please advise why these errors are appearing as we are using the files as provided
Following the instructions given on [(https://api.cloudmersive.com/salesforce-apex-client.asp)], 'virus' tab we ran the following code through Anonymous Editor:
`SwagScanApi api = new SwagScanApi(); SwagClient client = api.getClient();
// Configure API key authorization: Apikey ApiKeyAuth Apikey = (ApiKeyAuth) client.getAuthentication('Apikey'); Apikey.setApiKey('YOUR API KEY');
Map params = new Map{ 'inputFile' => Blob.valueOf('Sample text file\nContents') };
try { // cross your fingers SwagVirusScanResult result = api.scanFile(params); System.debug(result); } catch (Swagger.ApiException e) { // ...handle your exceptions }`
Please advise why these errors are appearing as we are using the files as provided