Create Salesforce bulk API job with Workbench
In this module we will learn how to create bulk API job and integrate with salesforce. Bulk API is a RESTful operation so we will use workbench to get this done
[** Go : https://workbench.developerforce.com > Utilities > REST Explorer]
a. endpoint : /services/async/39.0/job
b. method/call : POST
c. Header :
-------
Content-Type: application/json; charset=UTF-8
Accept: application/json
X-SFDC-Session: <SessionID>
-------
d. Body:
-------
{
"operation":"insert",
"object":"Account",
"contentType":"JSON"
}
-------
e. Click "Execute"
Result:
-------
{
"apexProcessingTime":0,
"apiActiveProcessingTime":0,
"apiVersion":39.0,
"assignmentRuleId":null,
"concurrencyMode":"Parallel",
"contentType":"JSON",
"createdById":"0057F000000YZX4QAO",
"createdDate":"2017-04-20T05:38:35.000+0000",
"externalIdFieldName":null,
"fastPathEnabled":false,
"id":"7507F000000XjWzQAK",
"numberBatchesCompleted":0,
"numberBatchesFailed":0,
"numberBatchesInProgress":0,
"numberBatchesQueued":0,
"numberBatchesTotal":0,
"numberRecordsFailed":0,
"numberRecordsProcessed":0,
"numberRetries":0,
"object":"Account",
"operation":"insert",
"state":"Open",
"systemModstamp":"2017-04-20T05:38:35.000+0000",
"totalProcessingTime":0
}
-------
************
[** Go : https://workbench.developerforce.com > Utilities > REST Explorer]
Part I : Create bulkAPI job and it's batch:
==============================
Step 1) Create/open a job (using workbech)
************a. endpoint : /services/async/39.0/job
b. method/call : POST
c. Header :
-------
Content-Type: application/json; charset=UTF-8
Accept: application/json
X-SFDC-Session: <SessionID>
-------
d. Body:
-------
{
"operation":"insert",
"object":"Account",
"contentType":"JSON"
}
-------
e. Click "Execute"
Result:
-------
{
"apexProcessingTime":0,
"apiActiveProcessingTime":0,
"apiVersion":39.0,
"assignmentRuleId":null,
"concurrencyMode":"Parallel",
"contentType":"JSON",
"createdById":"0057F000000YZX4QAO",
"createdDate":"2017-04-20T05:38:35.000+0000",
"externalIdFieldName":null,
"fastPathEnabled":false,
"id":"7507F000000XjWzQAK",
"numberBatchesCompleted":0,
"numberBatchesFailed":0,
"numberBatchesInProgress":0,
"numberBatchesQueued":0,
"numberBatchesTotal":0,
"numberRecordsFailed":0,
"numberRecordsProcessed":0,
"numberRetries":0,
"object":"Account",
"operation":"insert",
"state":"Open",
"systemModstamp":"2017-04-20T05:38:35.000+0000",
"totalProcessingTime":0
}
-------
************
Step 2) Create and push batch (copy the the id from previous result)
************
a. endpoint : /services/async/39.0/job/7507F000000XjWzQAK/batch
b. method/call : POST
c. Header : <Should be same as mentioned in 1st Step>
d. Body: (you push records maximum 10000 in 1 batch, below we will push 10 )
-------
[
{
"name": "Insuron Bulk Company"
},
{
"name": "Orboid Bulk Company"
},
{
"name": "Bovis Bulk Company"
},
{
"name": "Roughies Bulk Company"
},
{
"name": "Otherside Bulk Company"
},
{
"name": "Endipin Bulk Company"
},
{
"name": "Austech Bulk Company"
},
{
"name": "Quility Bulk Company"
},
{
"name": "Bleendot Bulk Company"
},
{
"name": "Apex Bulk Company"
}
]
-------
e. click : Execute
Result:
-------
{
"apexProcessingTime":0,
"apiActiveProcessingTime":0,
"createdDate":"2017-04-20T05:40:20.000+0000",
"id":"7517F000000XjTEQA0",
"jobId":"7507F000000XjWzQAK",
"numberRecordsFailed":0,
"numberRecordsProcessed":0,
"state":"Queued",
"stateMessage":null,
"systemModstamp":"2017-04-20T05:40:20.000+0000",
"totalProcessingTime":0
}
-------
************
Step 3) Close the job (using same id mentioned in step 1 result)
************
a. endpoint : /services/async/39.0/job/7507F000000XjWzQAK
b. method/call : POST
c. Header : <Should be same as mentioned in 1st Step>
d. body :
--------
{
"state":"Closed"
}
--------
e. click : Execute
Result:
--------
{
"apexProcessingTime":1779,
"apiActiveProcessingTime":1672,
"apiVersion":39.0,
"assignmentRuleId":null,
"concurrencyMode":"Parallel",
"contentType":"JSON",
"createdById":"0057F000000YZX4QAO",
"createdDate":"2017-04-20T05:38:35.000+0000",
"externalIdFieldName":null,
"fastPathEnabled":false,
"id":"7507F000000XjWzQAK",
"numberBatchesCompleted":1,
"numberBatchesFailed":0,
"numberBatchesInProgress":0,
"numberBatchesQueued":0,
"numberBatchesTotal":1,
"numberRecordsFailed":0,
"numberRecordsProcessed":10,
"numberRetries":0,
"object":"Account",
"operation":"insert",
"state":"Closed",
"systemModstamp":"2017-04-20T05:38:35.000+0000",
"totalProcessingTime":1888
}
--------
************
Part II : How to get current job details:
==============================
1) Get job details :
************
a. endpoint : /services/async/39.0/job/7507F000000XjWzQAK
b. method/call : GET
c. Header : <Should be same as 1st Step, in [I] module >
d. click : Execute
Result :
---------
{
"apexProcessingTime":1779,
"apiActiveProcessingTime":1672,
"apiVersion":39.0,
"assignmentRuleId":null,
"concurrencyMode":"Parallel",
"contentType":"JSON",
"createdById":"0057F000000YZX4QAO",
"createdDate":"2017-04-20T05:38:35.000+0000",
"externalIdFieldName":null,
"fastPathEnabled":false,
"id":"7507F000000XjWzQAK",
"numberBatchesCompleted":1,
"numberBatchesFailed":0,
"numberBatchesInProgress":0,
"numberBatchesQueued":0,
"numberBatchesTotal":1,
"numberRecordsFailed":0,
"numberRecordsProcessed":10,
"numberRetries":0,
"object":"Account",
"operation":"insert",
"state":"Closed",
"systemModstamp":"2017-04-20T05:41:57.000+0000",
"totalProcessingTime":1888
}
---------
*************
2) Batches details : (All batches in parent ID)
*************
a. endpoint : /services/async/39.0/job/7507F000000XjWzQAK/batch
b. method/call : GET
c. Header : <Should be same as 1st Step, in [I] module >
d. click : Execute
Result :
----------
{
"batchInfo":
[
{
"apexProcessingTime":1779,
"apiActiveProcessingTime":1672,
"createdDate":"2017-04-20T05:40:20.000+0000",
"id":"7517F000000XjTEQA0",
"jobId":"7507F000000XjWzQAK",
"numberRecordsFailed":0,
"numberRecordsProcessed":10,
"state":"Completed",
"stateMessage":null,
"systemModstamp":"2017-04-20T05:40:22.000+0000",
"totalProcessingTime":1888
}
]
}----------
*************
3) Batch details : (specifically 1 batch details)
*************
a. endpoint : /services/async/39.0/job/7507F000000XjWzQAK/batch/7517F000000XjTEQA0/result
b. method/call : GET
c. Header : <Should be same as 1st Step, in [I] module >
d. click : Execute
Result :
----------
[ {
"success" : true,
"created" : true,
"id" : "0017F000002XrPnQAK",
"errors" : [ ]
}, {
"success" : true,
"created" : true,
"id" : "0017F000002XrPoQAK",
"errors" : [ ]
}, {
"success" : true,
"created" : true,
"id" : "0017F000002XrPpQAK",
"errors" : [ ]
}, {
"success" : true,
"created" : true,
"id" : "0017F000002XrPqQAK",
"errors" : [ ]
}, {
"success" : true,
"created" : true,
"id" : "0017F000002XrPrQAK",
"errors" : [ ]
}, {
"success" : true,
"created" : true,
"id" : "0017F000002XrPsQAK",
"errors" : [ ]
}, {
"success" : true,
"created" : true,
"id" : "0017F000002XrPtQAK",
"errors" : [ ]
}, {
"success" : true,
"created" : true,
"id" : "0017F000002XrPuQAK",
"errors" : [ ]
}, {
"success" : true,
"created" : true,
"id" : "0017F000002XrPvQAK",
"errors" : [ ]
}, {
"success" : true,
"created" : true,
"id" : "0017F000002XrPwQAK",
"errors" : [ ]
}
]
----------
*************
1) Get job details :
************
a. endpoint : /services/async/39.0/job/7507F000000XjWzQAK
b. method/call : GET
c. Header : <Should be same as 1st Step, in [I] module >
d. click : Execute
Result :
---------
{
"apexProcessingTime":1779,
"apiActiveProcessingTime":1672,
"apiVersion":39.0,
"assignmentRuleId":null,
"concurrencyMode":"Parallel",
"contentType":"JSON",
"createdById":"0057F000000YZX4QAO",
"createdDate":"2017-04-20T05:38:35.000+0000",
"externalIdFieldName":null,
"fastPathEnabled":false,
"id":"7507F000000XjWzQAK",
"numberBatchesCompleted":1,
"numberBatchesFailed":0,
"numberBatchesInProgress":0,
"numberBatchesQueued":0,
"numberBatchesTotal":1,
"numberRecordsFailed":0,
"numberRecordsProcessed":10,
"numberRetries":0,
"object":"Account",
"operation":"insert",
"state":"Closed",
"systemModstamp":"2017-04-20T05:41:57.000+0000",
"totalProcessingTime":1888
}
---------
*************
2) Batches details : (All batches in parent ID)
*************
a. endpoint : /services/async/39.0/job/7507F000000XjWzQAK/batch
b. method/call : GET
c. Header : <Should be same as 1st Step, in [I] module >
d. click : Execute
Result :
----------
{
"batchInfo":
[
{
"apexProcessingTime":1779,
"apiActiveProcessingTime":1672,
"createdDate":"2017-04-20T05:40:20.000+0000",
"id":"7517F000000XjTEQA0",
"jobId":"7507F000000XjWzQAK",
"numberRecordsFailed":0,
"numberRecordsProcessed":10,
"state":"Completed",
"stateMessage":null,
"systemModstamp":"2017-04-20T05:40:22.000+0000",
"totalProcessingTime":1888
}
]
}----------
*************
3) Batch details : (specifically 1 batch details)
*************
a. endpoint : /services/async/39.0/job/7507F000000XjWzQAK/batch/7517F000000XjTEQA0/result
b. method/call : GET
c. Header : <Should be same as 1st Step, in [I] module >
d. click : Execute
Result :
----------
[ {
"success" : true,
"created" : true,
"id" : "0017F000002XrPnQAK",
"errors" : [ ]
}, {
"success" : true,
"created" : true,
"id" : "0017F000002XrPoQAK",
"errors" : [ ]
}, {
"success" : true,
"created" : true,
"id" : "0017F000002XrPpQAK",
"errors" : [ ]
}, {
"success" : true,
"created" : true,
"id" : "0017F000002XrPqQAK",
"errors" : [ ]
}, {
"success" : true,
"created" : true,
"id" : "0017F000002XrPrQAK",
"errors" : [ ]
}, {
"success" : true,
"created" : true,
"id" : "0017F000002XrPsQAK",
"errors" : [ ]
}, {
"success" : true,
"created" : true,
"id" : "0017F000002XrPtQAK",
"errors" : [ ]
}, {
"success" : true,
"created" : true,
"id" : "0017F000002XrPuQAK",
"errors" : [ ]
}, {
"success" : true,
"created" : true,
"id" : "0017F000002XrPvQAK",
"errors" : [ ]
}, {
"success" : true,
"created" : true,
"id" : "0017F000002XrPwQAK",
"errors" : [ ]
}
]
----------
*************
You made some good points here. I did a search on the Salesforce Developer and found most people will agree with this. Also Visit this site for to learn more about Salesforce Developer Online Training.
ReplyDeletevery informative blog and useful article thank you for sharing with us , keep posting learn more aboutsalesforce training salesforce Online Training
ReplyDeletekayseriescortu.com - alacam.org - xescortun.com
ReplyDeleteFon Perde Modelleri
ReplyDeleteMOBİL ONAY
mobil ödeme bozdurma
Nft Nasıl Alinir
Ankara evden eve nakliyat
Trafik sigortasi
dedektör
web sitesi kurma
AŞK ROMANLARI
tuzla toshiba klima servisi
ReplyDeleteçekmeköy lg klima servisi
ataşehir lg klima servisi
çekmeköy alarko carrier klima servisi
ataşehir alarko carrier klima servisi
çekmeköy daikin klima servisi
ataşehir daikin klima servisi
ümraniye lg klima servisi
kartal alarko carrier klima servisi