Bulk Write Job Details

Purpose

To get the details of a bulk write job performed previously.

Request Details

Request URL

{api-domain}/crm/bulk/{version}/write/{job_id}
where job_id is the unique ID of the bulk write job.

Header

Authorization: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52

Scope

scope=ZohoCRM.bulk.CREATE
(or)
scope=ZohoCRM.bulk.ALL

Sample request

Copiedcurl "https://www.zohoapis.com/crm/bulk/v2.1/write/111111000002308098"
-X GET
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
4.0.0
Copied//Get instance of BulkWriteOperations Class
$bulkWriteOperations = new BulkWriteOperations();
//Call getBulkWriteJobDetails method that takes jobId as parameter
$response = $bulkWriteOperations->getBulkWriteJobDetails($jobId);
Copied<?php
class GetBulkWriteJobDetails{
    
    public function execute(){
        $curl_pointer = curl_init();
        $url = "https://www.zohoapis.com/crm/bulk/v2.1/write/3524033000006012002";

        $curl_options = array();
        $curl_options[CURLOPT_URL] =$url;
        $curl_options[CURLOPT_RETURNTRANSFER] = true;
        $curl_options[CURLOPT_HEADER] = 1;
        $curl_options[CURLOPT_CUSTOMREQUEST] = "GET";
        $headersArray = array();
        
        $headersArray[] = "Authorization". ":" . "Zoho-oauthtoken " . "1000.bb75e76fXXXXX996e043dcfbb.5e2XXXXX6437c8d9f536e";
        
        $curl_options[CURLOPT_HTTPHEADER]=$headersArray;
        
        curl_setopt_array($curl_pointer, $curl_options);
        
        $result = curl_exec($curl_pointer);
        $responseInfo = curl_getinfo($curl_pointer);
        curl_close($curl_pointer);
        list ($headers, $content) = explode("\r\n\r\n", $result, 2);
        if(strpos($headers," 100 Continue")!==false){
            list( $headers, $content) = explode( "\r\n\r\n", $content , 2);
        }
        $headerArray = (explode("\r\n", $headers, 50));
        $headerMap = array();
        foreach ($headerArray as $key) {
            if (strpos($key, ":") != false) {
                $firstHalf = substr($key, 0, strpos($key, ":"));
                $secondHalf = substr($key, strpos($key, ":") + 1);
                $headerMap[$firstHalf] = trim($secondHalf);
            }
        }
        $jsonResponse = json_decode($content, true);
        if ($jsonResponse == null && $responseInfo['http_code'] != 204) {
            list ($headers, $content) = explode("\r\n\r\n", $content, 2);
            $jsonResponse = json_decode($content, true);
        }
        var_dump($headerMap);
        var_dump($jsonResponse);
        var_dump($responseInfo['http_code']);
        
    }
    
}
(new GetBulkWriteJobDetails())->execute();
2.1.0
Copied# Get instance of BulkWriteOperations Class
bwo = BulkWrite::BulkWriteOperations.new
# Call get_bulk_write_job_details method that takes job_id as parameter
response = bwo.get_bulk_write_job_details(job_id)
Copiedrequire 'net/http'
require 'json'

class GettheStatusoftheBulkReadJob 

    def execute
        parameters ={}
        parameters["job_id"]="3524033000006027001"
        query_string = parameters.to_a.map { |x| "#{x[0]}=#{x[1]}" }.join('&')
        url= "https://www.zohoapis.com/crm/bulk/v2.1/write/3524033000006012002"
        url += '?' + query_string if !query_string.nil? && (query_string.strip != '')
        url = URI(url)
        req = Net::HTTP::Get.new(url.request_uri)
        http = Net::HTTP.new(url.host, url.port)
        http.use_ssl = true
        headers={}
        headers["Authorization"]="Zoho-oauthtoken 1000.dfa7XXXXXXXXXXXXXXXXXX84f9665840.c176aeXXXXXXXXXXXX13f3d37a84d"
        headers["Content-Type"]="application/json"
        headers&.each { |key, value| req.add_field(key, value) }
        response=http.request(req)
        status_code = response.code.to_i
        headers = response.each_header.to_h
        print status_code
        print headers
        unless response.body.nil?
            print  response.body
        end
    end
end
GettheStatusoftheBulkReadJob.new.execute

Response Structure

  • statusstring

    Specifies the current status of the bulk write job. Example: "status": "ADDED" or "IN PROGRESS" or "COMPLETED".

  • character_encodingstring

    Specifies the character encoding for the bulk write job. The system detects the character encoding automatically. However, if you specify, it will take precedence.

  • idstring

    Specifies the unique identifier of the bulk write job.

  • resultJSON object

    download_url: Represents the download URL from which you can download the result (CSV file) of the bulk write job after its successful completion.

  • created_byJSON Object

    Specifies the ID and Name of the user who initiated the bulk read job.

  • operationstring

    Specifies the type of bulk write operation performed. Sample: "operation": "insert".

  • created_timeISO8601

    Specifies the date and time at which the bulk write job was initialized.

  • resourceJSON Object

    Contains the details about the module selected, the field mappings, and the ID of the file used for this job.

    • status, string - The status of the bulk write job for that module. Example: "status": "ADDED", "IN PROGRESS", "COMPLETED", "SKIPPED", or "FAILED".

    • type, string - The type of module that you have imported. The value is data.

    • modulestring - The API name of the module that you have imported the records from.

    • field_mappings, JSON object - Contains the following keys:

      • api_name, string - The API name of the field present in the Zoho module object that you want to import into.

      • find_by, string - The API name of the unique field or primary field(record ID) in the module. The system uses this API name to find the existing records in CRM.

      • index, integer - The column index of the field you want to map to the CRM field.

      • default_valueJSON object - The default value with which the system replaces any partial or empty file column in the CSV file.

  • fileJSON Object

    Contains the following details about the import:

    • status, string - The status of the bulk write job for that module. Example: "status": "ADDED", "IN PROGRESS", "COMPLETED", "SKIPPED", or "FAILED".

    • name, string - The name of the CSV file which will get downloaded.

    • module, string - The API name of the module that you have imported the records from.

    • added_count, integer - The number of records added or imported.

    • skipped_count, integer - The number of records skipped due to some issues. The Error column in the CSV file will have details about why the record was skipped during import.

    • updated_count, integer - The number of records updated during bulk update.

    • total_count, integer - The total number of records inserted, updated, or skipped during bulk import.

Note

To know about the Bulk Write API limits, go here.

Possible Errors

  • INVALID_URL_PATTERNHTTP 404

    Please check if the URL trying to access is a correct one
    Resolution: The request URL specified is incorrect. Specify a valid request URL. Refer to request URL section above.

  • OAUTH_SCOPE_MISMATCHHTTP 401

    Unauthorized
    Resolution: Client does not have ZohoCRM.bulk.CREATE. Create a new client with valid scope. Refer to scope section above.

  • NO_PERMISSIONHTTP 403

    Permission denied to read
    Resolution: The user does not have permission to get the details of a bulk write job. Contact your system administrator.

  • INTERNAL_ERRORHTTP 500

    Internal Server Error
    Resolution: Unexpected and unhandled exception in Server. Contact support team.

  • INVALID_REQUEST_METHODHTTP 400

    The http request method type is not a valid one
    Resolution: You have specified an invalid HTTP method to access the API URL. Specify a valid request method. Refer to endpoints section above.

  • AUTHORIZATION_FAILEDHTTP 400

    User does not have sufficient privilege to read.
    Resolution: The user does not have the permission to get the details of a bulk write job. Contact your system administrator.

  • RESOURCE_NOT_FOUNDHTTP 404

    The requested resource doesn't exist.
    Resolution: The job ID specified is invalid. Specify a valid job ID.

Sample response for job "Added"

Copied{
  "status": "ADDED",
  "resource": [
    {
      "status": "INPROGRESS",
      "code":"ADDED"
      "type": "data",
      "module": { "api_name": "Deals", "id": "3652397000000002181" }
      "field_mappings": [
        {
          "api_name": "Deal_Name",
          "index": 1,
          "format": null,
          "find_by": null,
          "default_value": null
        },
        {
          "api_name": "Stage",
          "index": 132,
          "format": null,
          "find_by": null,
          "default_value": null
        }
      ],
      "file": {
        "status": "INPROGRESS"
      }
    }
  ],
  "id": "111111000002308098",
  "created_by": {
    "id": "111111000000035795",
    "name": "Patricia Boyle"
  },
  "operation": "insert",
  "created_time": "2019-01-30T02:21:32-12:00"
}

Sample response for job "In Progress"

Copied{
  "status": "INPROGRESS",
  "character_encoding": "UTF-8",
  "resource": [
    {
      "status": "INPROGRESS",
      "code":"ADDED",
      "type": "data",
      "module": { "api_name": "Deals", "id": "3652397000000002181" }
      "field_mappings": [
        {
          "api_name": "Deal_Name",
          "index": 1,
          "format": null,
          "find_by": null,
          "default_value": null
        },
        {
          "api_name": "Stage",
          "index": 2,
          "format": null,
          "find_by": null,
          "default_value": null
        }
      ],
      "file": {
        "status": "INPROGRESS",
        "name": "Accounts.csv",
        "added_count": 0,
        "skipped_count": 100,
        "updated_count": 0,
        "total_count": 100
      }
    }
  ],
  "id": "111111000002308051",
  "created_by": {
    "id": "111111000000035795",
    "name": "Patricia Boyle"
  },
  "operation": "insert",
  "created_time": "2019-01-30T02:18:15-12:00"
}

Sample response for job "Completed"

Copied{
  "status": "COMPLETED",
  "character_encoding": "UTF-8",
  "resource": [
    {
      "status": "COMPLETED",
      "type": "data",
      "code":"SUCCESS",
       "module": { "api_name": "Deals", "id": "3652397000000002181" }
      "field_mappings": [
        {
          "api_name": "Deal_Name",
          "index": 1,
          "format": null,
          "find_by": null,
          "default_value": null
        },
        {
          "api_name": "Stage",
          "index": 2,
          "format": null,
          "find_by": null,
          "default_value": null
        }
      ],
      "file": {
        "status": "COMPLETED",
        "name": "Deals.csv",
        "added_count": 0,
        "skipped_count": 100,
        "updated_count": 0,
        "total_count": 100
      }
    }
  ],
  "id": "111111000002308051",
  "result": {
    "download_url": "/v2.1/crm/org6196138/bulk-write/111111000002308051/111111000002308051.zip"
  },
  "created_by": {
    "id": "111111000000035795",
    "name": "Patricia Boyle"
  },
  "operation": "insert",
  "created_time": "2019-01-30T02:18:15-12:00"
}