Salesforce Bulk API 2.0 – DZone – Uplaza

Have you ever ever confronted the problem of managing massive knowledge operations inside Salesforce, akin to updating, inserting, deleting, or querying data? These operations may come up from one-time knowledge migration initiatives or ongoing knowledge integration wants with exterior methods. In such situations, Salesforce Bulk API 2.0 is your resolution. This strong API is designed to deal with large-scale knowledge operations effectively, simplifying and streamlining the method.

Salesforce Bulk API 2.0 is a REST-based API, that runs the requested operation asynchronously. It’s designed to simplify bulk operations inside Salesforce in addition to to enhance the efficiency and reliability of bulk knowledge processing. The next are key options of Bulk API 2.0. 

1. Simplified Bulk Information Administration

You solely have to create one job for every knowledge operation and Salesforce will deal with breaking down the information set into a number of batches. This considerably reduces the effort and time wanted for big knowledge migrations or batch operations. 

2. Reliability and Efficiency

Salesforce optimizes inner batch splits and execution for you. Salesforce additionally routinely executes retries when an error happens and helps partial knowledge processing. Which means that even when some data fail, the profitable ones are processed, and customers obtain clear suggestions on the errors encountered. 

3. Asynchronous Processing

Bulk API 2.0 processes the requests asynchronously, that means the batches run within the background. This permits customers to proceed with different duties with out ready for the operation to finish. 

4. Helps JSON

The API helps JSON format for job creation and standing checks. 

How To Use Bulk API 2.0

To make use of Bulk API 2.0, you want to comply with the next steps. Allow us to take an instance of an replace operation on the Alternative desk.   

1. Create a Job

Step one is to create the job with operation = replace, by sending a POST request with the next particulars. 

endpoint:  /companies/knowledge/vXX.X/jobs/ingest

payload: lineEnding request parameter is the line-ending format used within the CSV. The API helps two line-ending codecs: linefeed (LF), and carriage-return plus linefeed (CRLF). 

{
    "object" : "Opportunity",
    "contentType" : "CSV",
    "operation" : "update",
    "lineEnding" : "LF"
}

response: You’ll get the response with the job ID. You can be utilizing this Job ID in additional steps. The standing of the job is ‘Open’. 

You too can go to Setup>Monitor Bulk Information Load Jobs to observe the progress of the roles.

2. Add Information

As soon as the job is created, the subsequent step is to add your knowledge that wants an replace. That you must ship a PUT request to the next endpoint, with the information for the job in CSV format. You may add as much as 150 MB of information per job. 

endpoint: /companies/knowledge/vXX.X/jobs/ingest/{jobId}/batches

3. Set Job State to Uploadcomplete

As soon as the add is full, notify Salesforce servers that it’s time to course of the information.  To do that, ship a PATCH request to the next endpoint. 

endpoint: /companies/knowledge/vXX.X/jobs/ingest/{jobId}/

payload

{ "state" : "UploadComplete" }

response: Job standing is modified to UploadComplete

4. Examine the Standing

If you wish to test the standing of the job and, the variety of data processed, errored out, and unprocessed, you may ship a GET request to the next endpoint. 

endpoint: /companies/knowledge/vXX.X/jobs/ingest/{jobId}

response

{ "id" : "7505fEXAMPLE4C2AAM",
"operation" : "update",
"object" : "Opportunity",
"createdById" : "0055fEXAMPLEtG4AAM",
"createdDate" : "2022-01-02T21:33:43.000+0000",
"systemModstamp" : "2022-01-02T21:38:31.000+0000",
"state" : "JobComplete",
"concurrencyMode" : "Parallel",
"contentType" : "CSV",
 "apiVersion" : 61.0,
"jobType" : "V2Ingest",
"lineEnding" : "LF",
"columnDelimiter" : "COMMA",
"numberRecordsProcessed" : 7,
"numberRecordsFailed" : 0,    
"retries" : 0,
"totalProcessingTime" : 886,
"apiActiveProcessingTime" : 813,
"apexProcessingTime" : 619 }

You too can ship a GET request to /companies/knowledge/vXX.X/jobs/ingest/{jobId}/failedResults endpoint to get the main points of the failed data OR 

to /companies/knowledge/v61.0/jobs/ingest/{jobId}/successfulResults/

endpoint to get particulars about which data have been efficiently processed.

Use Circumstances of Bulk API 2.0

Information Migration

Bulk API 2.0 is right for migrating massive knowledge units from legacy methods to Salesforce. Its potential to course of tens of millions of information effectively makes it the primary choice for large-scale operations. 

Information Integration

When you’ve knowledge integration necessities, integrating exterior methods to Salesforce, Bulk API 2.0 supplies a strong resolution. Its help for asynchronous processing makes large-scale knowledge integration environment friendly, because it ensures that knowledge could be built-in with out disrupting ongoing operations. 

Batch Processing

Routine batch processing jobs, akin to nightly knowledge cleanups, could be streamlined utilizing Bulk API 2.0. Its error-handling capabilities make it perfect for routine knowledge operations. 

Conclusion

Salesforce Bulk API 2.0 is a important device for organizations to handle large-scale knowledge operations effectively. Its functionality to course of tens of millions of information successfully, with strong error dealing with and help for asynchronous processing, makes this a go-to device for any knowledge migration, knowledge integration, or batch processing initiatives.

Share This Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Exit mobile version