AI Scoring API: Get File

The scoring getfile API allows users to get the validation results file for the file been submitted using scoring sendfile API. Please refer to the C# example for details.

GET /V2/SCORING/GETFILE

API URL: https://bulkapi.zerobounce.net/v2/scoring/getfile

URL Parameters

  • Parameter
    Required/Optional
    Description
  • api_key
    Required
    Your API Key, found in your account
  • file_id
    Required
    The returned file ID when calling scoring sendfile API

Get File Code Samples

  • Visual Basic
  • C#
  • PHP
  • Java
  • Python
  • Swift
      
' 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/scoring/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
   

// 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/scoring/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

 $request = new HttpRequest();
 $request->setUrl('https://bulkapi.zerobounce.net/v2/scoring/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;
 }
 ?>
   

 OkHttpClient client = new OkHttpClient();

 Request request = new Request.Builder()
   .url("https://bulkapi.zerobounce.net/v2/scoring/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();
   

 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"))
 
   
   

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/scoring/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

      
{
 "success": true,
 "message": "File Accepted",
 "file_name": "Your file name.csv",
 "file_id": "aaaaaaaa-zzzz-xxxx-yyyy-5003727fffff"
}
   

Error Response

      
   {
     "success": false,
     "message": [
         "Error messages"
     ]
 }