Post a File and Data to SandBlast API using Postman and generate C# code
We got a requirement to use SandBlast Threat Extraction process, for cleansing the files.
SandBlast Threat Extraction, is a solution by ‘Check Point’ company, which removes exploitable content, including active content and embedded objects, reconstructs files to eliminate potential threats.
‘Threat Extraction’ Upload API, requires following parameters
- Header
- Authorization
- Content-Type
- Body
- File Content
- request (This is string)
If you notice, we need to pass ‘File’ as well as ‘Data’ to the API.
As of now, Sandblast doesn’t have a native .Net library to make API calls. So I’ve used Postman tool as a starting point for my development.
Below is the step-by-step, to pass ‘File’ and ‘Data’ in request ‘Body’, using Postman
- Open Postman tool
- Create a new ‘Request’
- Set the method as ‘Post’ and URL.
- From the ‘Body’ tab, select ‘form-data’ option
- To pass the ‘File’, add a new ‘KEY’ of type ‘File’ and browse the file in ‘VALUE’ parameter.
- To pass the ‘Data’, add a new ‘KEY’ of type ‘Text’ and set the ‘VALUE’
Generate C# code from the Request:
- Postman has an amazing feature to generate the code in your required language.
- Click on ‘Code’ link and for C#, choose ‘C# (RestSharp)’ option.
- In your C# project, add RestSharp NuGet package.
- Paste the code in your class file and you are good to go now.
If anyone having struggling to use Sandblast API’s, post in comments section and I will address.
🙂