Close Menu
SalesforceCodex
    Facebook X (Twitter) Instagram
    Trending
    • 10 Salesforce Chrome Extensions to Boost Your Productivity
    • How to Build a Generic Modal Window in Lightning Web Component
    • Top 10 Salesforce Flow Features of Salesforce Summer ’25
    • Unlock the Power of Vibe Coding in Salesforce
    • How to Implement Dynamic Queueable Chaining in Salesforce Apex
    • How to Implement Basic Queueable Chaining in Salesforce Apex
    • How to Suppress PMD Warnings in Salesforce Apex
    • Top 10 PMD Issues Salesforce Developers Should Focus on in Apex
    Facebook X (Twitter) Instagram
    SalesforceCodex
    Subscribe
    Sunday, June 1
    • Home
    • Architecture
    • Salesforce
      • News
      • Apex
      • Integration
      • Books Testimonial
    • Questions
    • Certification
      • How to Prepare for Salesforce Integration Architect Exam
      • Certification Coupons
    • Integration Posts
    • Downloads
    • About Us
      • Privacy Policy
    SalesforceCodex
    Home»Salesforce»Certification»Using Salesforce Bulk API V1

    Using Salesforce Bulk API V1

    Dhanik Lal SahniBy Dhanik Lal SahniDecember 9, 2020Updated:January 12, 2025No Comments5 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email
    Using Salesforce Bulk API V1
    Share
    Facebook Twitter LinkedIn Pinterest Email

    Salesforce Bulk API is required when we need to process high volume of data in Salesforce. This is quickest way to load data using programmatic ways.

    When to use Salesforce Bulk API?

    • Bulk API is based on REST principles and is optimized for loading or deleting large sets of data. Example: You have new client and they want to move their data from existing system to Salesforce.
    • Salesforce processes batches in the background. So there is no problem of network speed. Once the records are upload, Salesforce will process it internally.
    • We can easily control API calls using standard features (setup menu).
    • We can also load data with Data Loader using CSV files
    • Easiest way to use Bulk API is to enable it for processing records in Data Loader using CSV files.

    Parallel Vs Serial Mode

    We can process record using Bulk API V1.0 or V2.0. By default bulk API records are process using parallel mode, where multiple records are process in multiple batches. It might throw record lock or record lookup issue. Record lookup issue is where one records is being processed in one batch and referenced record is being processed in other batch, so it will create issue in processing. To avoid that situation we can go with serial mode or we can organize related records in same batch.

    Serial mode processing is only possible in Bulk API V1.0. Bulk API V2.0 only process record in parallel mode.

    How to process record in bulk API

    Let us see how we can process record using Bulk API V1.0. For processing records we need below steps

    1. Login to Salesforce to get authorization token.
    2. Create bulk job
    3. Add batch to job
    4. Close job to start processing
    5. Get Job Status

    We are using POSTMAN to execute Bulk API with above steps. In real implementation, POSTMAN request can be changed to specific language code. As we need to call Salesforce Bulk API from other system (in this case POSTMAN), we need connected app for this. So create one connected app in your Salesforce Orgs.

    Creating Connected App:

    A connected app is a framework that enables an external application like ASP.NET, Java etc. to integrate with Salesforce using APIs and standard protocols. Connected app can be created from Setup menu. Set below detail to create connected app.

    App PropertyDescription/Values
    Connected App NameExternal System App
    Contact Emailput your email
    Enable OAuth Settingchecked
    Callback Urlhttps://www.getpostman.com/oauth2/callback 
    Selecte OAuth Usage1. Access and manage your data (api)
    2. Provide access to your data via the Web
    3. Perform requests on your behalf at any time (refresh-token, offline_access)
    Connected App for Using Salesforce Bulk API- SalesforceCodex

    Once connected app created, we will get Consumer Key and Consumer Secret. These detail along with Salesforce user will be used to run Bulk API in POSTMAN.

    Let us start step by step process to process record using Bulk API.

    1. Login to Salesforce to get Session Id

    Bulk API V1.0 is a built as custom REST API, it is not a standard REST API technology. In V1.0, session id is used as token in next API calls. For getting session id, we have to use SOAPAction in login request. Ideally this is a SOAP request.

    Login Request:

    Login Urlhttps://login.salesforce.com/services/Soap/c/50.0/
    Http MethodPOST
    Headers Sections
    Content-Typetext/xml
    Accept-Encodingtext/xml;charset=UTF-8
    SOAPAction“” <blank value>

    Based on above request, Session id (highlighted) will be generated. Generated session id will be used in next steps API calls.

    Session ID Generation Request in Using Salesforce Bulk API - SalesforceCodex

    2. Create bulk job

    After session id is generated from first step. Let us create bulk job to process record. Job can be created for XML or JSON based request.

    Session Id which is generated in first step is passed as http header X-SFDC-Session property.

    API PropertyValues
    API Url{{instanceUrl}}/services/async/{{apiversion}}/job/’
    Http MethodPOST
    Http Header:
    X-SFDC-Session
    <session id which is generated from first step>
    Body (raw)<?xml version=”1.0″ encoding=”UTF-8″?>
    <jobInfo
    xmlns=”http://www.force.com/2009/06/asyncapi/dataload”>
    <operation>insert</operation>
    <object>Account</object>
    <contentType>XML</contentType>
    </jobInfo>

    In this request body xml, we are passing below values

    • operation: What kind of DML operation need to perform using Bulk API.
    • object: On which object these DML operation will be performed.
    • contentType : How the request will be processed, XML or CSV records.
    Bulk API Job Creation - SalesforceCodex

    Job Id is created after response is generated. This job id is required for batch job processing. This is mandatory for next API calls.

    3. Add batch to Job

    In this step we will upload data which need to be processed. This can be done in multiple ways. If you need to upload file directly use binary option in body or if you want to process record directly then use raw type. In case of binary, you will select file which need to process.

    API PropertyValues
    API Url{{instanceUrl}}/services/async/50.0/job/{{apiversion}}/batch
    Http MethodPOST
    Http Headers
    X-SFDC-Session<Session Id generated in first step>
    Content-Typeapplication/xml or text/csv
    Body(raw-xml)<?xml version=”1.0″ encoding=”UTF-8″?>
    <sObjects xmlns=”http://www.force.com/2009/06/asyncapi/dataload”>
    <sObject>
    <description>Created from Bulk API</description>
    <name>[Bulk API] Account 0 (batch 0)</name>
    </sObject>
    <sObject>
    <description>Created from Bulk API</description>
    <name>[Bulk API] Account 1 (batch 0)</name>
    </sObject>
    </sObjects>
    Body(raw-csv)Name,FirstName__c,LastName__c,Phone,Email__c
    Dhanik,Dhanik,Sahni,740-6604,dhanik.sahni@yahoo.com
    Poorvansh,Poorvansh,Sahni,886-0190,poorva@yahoo.com
    Body(binary)Select file which need to processed

    Put body based on request type. If you are using XML based processing then use Body(raw-xml), when CSV based records need to be processed then use Body(raw-csv).

    We can upload multiple records by repeating this step.

    Add Batch to Bulk Job- SalesforceCodex

    To upload record data using files. Use binary body format to upload files.

    Add binary data in Bulk API - SalesforceCodex

    4. Close Job

    Once record is uploaded, we have to close job so that record processing will be started. This API request also informs Salesforce that no more batches will be submitted. To close job, below detail will be required.

    API PropertyValues
    API Url{{instanceUrl}}/services/async/{{apiversion}}/job/{{_jobId}}
    Http MethodPOST
    Http Headers
    X-SFDC-Session{{sessionid generated in first step}}
    Content-Typeapplication/json; charset=UTF-8
    Body (raw)<?xml version=”1.0″ encoding=”UTF-8″?>
    <jobInfo xmlns=”http://www.force.com/2009/06/asyncapi/dataload”>
    <state>Closed</state>
    </jobInfo>

    I have observed some time this step is not required and processing got started immediately after uploading batch is completed.

    5. Get Job Status

    Once job is closed for batch processing, we can check status of job processing. Below detail will be passed as API request to get status.

    API PropertyValue
    API Url{{instanceUrl}}/services/async/{{apiversion}}/job/{{_jobId}}/batch
    Http MethodGet
    Http Headers
    X-SFDC-Session{{session id generated in first step}}
    Bulk API Job Status - SalesforceCodex

    Video:

    Reference:

    Introduction to Bulk API

    https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/asynch_api_batches_intro.htm

    bulk api bulk api v1 BulkAPI connected app salesforce salesforce api integration salesforce bulk api
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleUML Sequence Diagram for Salesforce Integration
    Next Article Generate Public Link for Salesforce file
    Dhanik Lal Sahni
    • Website
    • Facebook
    • X (Twitter)

    With over 18 years of experience in web-based application development, I specialize in Salesforce technology and its ecosystem. My journey has equipped me with expertise in a diverse range of technologies including .NET, .NET Core, MS Dynamics CRM, Azure, Oracle, and SQL Server. I am dedicated to staying at the forefront of technological advancements and continuously researching new developments in the Salesforce realm. My focus remains on leveraging technology to create innovative solutions that drive business success.

    Related Posts

    By Dhanik Lal Sahni9 Mins Read

    10 Salesforce Chrome Extensions to Boost Your Productivity

    June 1, 2025
    By Dhanik Lal Sahni4 Mins Read

    How to Build a Generic Modal Window in Lightning Web Component

    May 26, 2025
    By Dhanik Lal Sahni6 Mins Read

    Top 10 Salesforce Flow Features of Salesforce Summer ’25

    May 11, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Ranked #1 SALESFORCE DEVELOPER BLOG BY SALESFORCEBEN.COM
    Featured on Top Salesforce Developer Blog By ApexHours
    Recent Posts
    • 10 Salesforce Chrome Extensions to Boost Your Productivity
    • How to Build a Generic Modal Window in Lightning Web Component
    • Top 10 Salesforce Flow Features of Salesforce Summer ’25
    • Unlock the Power of Vibe Coding in Salesforce
    • How to Implement Dynamic Queueable Chaining in Salesforce Apex
    Ranked in Top Salesforce Blog by feedspot.com
    RSS Recent Stories
    • How to Connect Excel to Salesforce to Manage Your Data and Metadata February 9, 2025
    • Difference Between With Security and Without Security in Apex January 2, 2025
    • Top Reasons to Love Salesforce Trailhead: A Comprehensive Guide December 5, 2024
    • How to Utilize Apex Properties in Salesforce November 3, 2024
    • How to Choose Between SOQL and SOSL Queries July 31, 2024
    Archives
    Categories
    Tags
    apex (111) apex code best practice (8) apex rest (11) apex trigger best practices (4) architecture (22) Asynchronous apex (9) AWS (5) batch apex (9) batch processing (4) code analysis (3) code optimization (8) custom metadata types (5) design principle (9) flow (15) future method (4) google (6) google api (4) integration (19) integration architecture (6) lighting (8) lightning (65) lightning-combobox (5) lightning-datatable (10) lightning component (31) Lightning web component (63) lwc (52) named credential (8) news (4) optimize apex code (4) optimize apex trigger (3) Permission set (4) pmd (3) Queueable (9) rest api (23) S3 Server (4) salesforce (142) salesforce apex (47) salesforce api (4) salesforce api integration (5) Salesforce Interview Question (4) salesforce news (5) salesforce question (5) solid (6) tooling api (5) Winter 20 (8)

    Get our newsletter

    Want the latest from our blog straight to your inbox? Chucks us your detail and get mail when new post is published.
    * indicates required

    Ranked #1 SALESFORCE DEVELOPER BLOG BY SALESFORCEBEN.COM
    Featured on Top Salesforce Developer Blog By ApexHours
    Recent Posts
    • 10 Salesforce Chrome Extensions to Boost Your Productivity
    • How to Build a Generic Modal Window in Lightning Web Component
    • Top 10 Salesforce Flow Features of Salesforce Summer ’25
    • Unlock the Power of Vibe Coding in Salesforce
    • How to Implement Dynamic Queueable Chaining in Salesforce Apex
    Ranked in Top Salesforce Blog by feedspot.com
    RSS Recent Stories
    • How to Connect Excel to Salesforce to Manage Your Data and Metadata February 9, 2025
    • Difference Between With Security and Without Security in Apex January 2, 2025
    • Top Reasons to Love Salesforce Trailhead: A Comprehensive Guide December 5, 2024
    • How to Utilize Apex Properties in Salesforce November 3, 2024
    • How to Choose Between SOQL and SOSL Queries July 31, 2024
    Archives
    Categories
    Tags
    apex (111) apex code best practice (8) apex rest (11) apex trigger best practices (4) architecture (22) Asynchronous apex (9) AWS (5) batch apex (9) batch processing (4) code analysis (3) code optimization (8) custom metadata types (5) design principle (9) flow (15) future method (4) google (6) google api (4) integration (19) integration architecture (6) lighting (8) lightning (65) lightning-combobox (5) lightning-datatable (10) lightning component (31) Lightning web component (63) lwc (52) named credential (8) news (4) optimize apex code (4) optimize apex trigger (3) Permission set (4) pmd (3) Queueable (9) rest api (23) S3 Server (4) salesforce (142) salesforce apex (47) salesforce api (4) salesforce api integration (5) Salesforce Interview Question (4) salesforce news (5) salesforce question (5) solid (6) tooling api (5) Winter 20 (8)

    Get our newsletter

    Want the latest from our blog straight to your inbox? Chucks us your detail and get mail when new post is published.
    * indicates required

    Facebook X (Twitter) Instagram Pinterest YouTube Tumblr LinkedIn Reddit Telegram
    © 2025 SalesforceCodex.com. Designed by Vagmine Cloud Solution.

    Type above and press Enter to search. Press Esc to cancel.

    Ad Blocker Enabled!
    Ad Blocker Enabled!
    Our website is made possible by displaying online advertisements to our visitors. Please support us by disabling your Ad Blocker.