Get File (v2)
The getfile API allows users to get the validation results file for the file been submitted using sendfile API. Please refer to the C# example for details.
GET /v2/getfile
API URL: https://bulkapi.zerobounce.net/v2/getfile
URL Parameters
- ParameterDescription
- api_keyYour API Key, found in your account.
- file_idThe returned file ID when calling sendfile API.
If you want to call the API from your browser to test it, all you have to do is to replace the API KEY with your key and the FILE ID with the returned file ID from sendfile API:
https://bulkapi.zerobounce.net/v2/getfile?api_key=replacewithyours&file_id=[replacewithyours]
GetFile Code Samples
' Complete API Libraries and Wrappers can be found here:
' https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__dot_net
' Get File Sample in VB.net
Private Shared Sub GetFileAPITest()
Dim apiKey As String = "replace with your api key here"
Dim fileID As String = "replace with the returned file ID when calling sendfile API"
Dim dir As String = "C: emp"
Try
Dim filePath = GetFileAsync(apiKey, fileID, dir).Result
Console.Write($"File {filePath} retrieved successfully.")
Catch ex As Exception
Console.Write(ex.InnerException.Message)
End Try
Console.ReadKey()
End Sub
Public Shared Async Function GetFileAsync(ByVal apiKey As String, ByVal fileID As String, ByVal dir As String) As Task(Of String)
If String.IsNullOrEmpty(apiKey) Then Throw New Exception("Error: apiKey is required")
If String.IsNullOrEmpty(fileID) Then Throw New Exception("Error: fileID is required")
Dim uri As Uri = New Uri($"https://bulkapi.zerobounce.net/v2/getfile?api_key={apiKey}&file_id={fileID}")
Using client = New HttpClient()
Using request = New HttpRequestMessage(HttpMethod.Get, uri)
Using response = Await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(False)
Using streamToReadFrom As Stream = Await response.Content.ReadAsStreamAsync()
If response.IsSuccessStatusCode = False Then
Dim [error] = $"StatusCode = {CInt(response.StatusCode)}, Content = {response.Content.ReadAsStringAsync().Result}"
Throw New Exception([error])
End If
Dim filePath = Path.Combine(dir, response.Content.Headers.ContentDisposition.FileName)
Using streamToWriteTo As Stream = File.Open(filePath, FileMode.Create)
Await streamToReadFrom.CopyToAsync(streamToWriteTo)
End Using
Return filePath
End Using
End Using
End Using
End Using
End Function
// Complete API Libraries and Wrappers can be found here:
// https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__dot_net
// https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__c-sharp
// Get File Sample in C#
private static void GetFileAPITest()
{
string apiKey = "replace with your api key here";
string fileID = "replace with the returned file ID when calling sendfile API";
string dir = @"C: emp"; // specify the directory where you want to save the results file
try
{
var filePath = GetFileAsync(apiKey, fileID, dir).Result;
Console.Write($"File {filePath} retrieved successfully.");
}
catch (Exception ex)
{
Console.Write(ex.InnerException.Message);
}
Console.ReadKey();
}
public static async Task<string> GetFileAsync(string apiKey, string fileID, string dir)
{
if (string.IsNullOrEmpty(apiKey))
throw new Exception("Error: apiKey is required");
if (string.IsNullOrEmpty(fileID))
throw new Exception("Error: fileID is required");
Uri uri = new Uri($"https://bulkapi.zerobounce.net/v2/getfile?api_key={apiKey}&file_id={fileID}");
using (var client = new HttpClient())
using (var request = new HttpRequestMessage(HttpMethod.Get, uri))
using (var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false))
using (Stream streamToReadFrom = await response.Content.ReadAsStreamAsync())
{
if (response.IsSuccessStatusCode == false)
{
var error = $"StatusCode = {(int)response.StatusCode}, Content = {response.Content.ReadAsStringAsync().Result}";
throw new Exception(error);
}
var filePath = Path.Combine(dir, response.Content.Headers.ContentDisposition.FileName);
using (Stream streamToWriteTo = File.Open(filePath, FileMode.Create))
{
await streamToReadFrom.CopyToAsync(streamToWriteTo);
}
return filePath;
}
}
<?php
// Complete API Libraries and Wrappers can be found here:
// https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__php
$request = new HttpRequest();
$request->setUrl('https://bulkapi.zerobounce.net/v2/getfile');
$request->setMethod(HTTP_METH_GET);
$request->setQueryData(array(
'api_key' => 'replacewithyours',
'file_id' => 'replacewithyours'
));
$request->setHeaders(array(
'Postman-Token' => '0a6c40b8-0cd4-4dbb-a57e-422558e7ab6a',
'cache-control' => 'no-cache'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
//Complete API Libraries and Wrappers can be found here:
//https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__java
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://bulkapi.zerobounce.net/v2/getfile?api_key=replacewithyours&file_id=replacewithyours")
.get()
.addHeader("cache-control", "no-cache")
.addHeader("Postman-Token", "d0b7d318-f3f6-47fb-842d-5622b26592c1")
.build();
Response response = client.newCall(request).execute();
# Complete API Libraries and Wrappers can be found here:
# https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__python
import http.client
conn = http.client.HTTPConnection("bulkapi,zerobounce,net")
payload = ""
headers = {
'cache-control': "no-cache",
'Postman-Token': "9f615d7e-60af-4746-9bcc-317b1f80a6bb"
}
conn.request("GET", "v2,getfile", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
// Complete API Libraries and Wrappers can be found here:
// https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__IOS
import Foundation
let headers = [
"cache-control": "no-cache",
"Postman-Token": "6c8cb1cb-25ed-4e56-b4cb-65e949b8bdd1"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://bulkapi.zerobounce.net/v2/getfile?api_key=replacewithyours&file_id=replacewithyours")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
Endpoint Response
Successful Response
//N/A
The getfile API returns the validation results file. The returned content type is "application/octet-stream". You can get the file name from response.Content.Headers.ContentDisposition.FileName. If you are calling the API directly from the browser, you can either save or open the results file from the browser.
Error Response
{
"success": false,
"message": "Error messages"
}