Back to Collection Items
LOCAL loHttp
LOCAL lnSuccess
LOCAL loJson
LOCAL loResp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lnApexProcessingTime
LOCAL lnApiActiveProcessingTime
LOCAL lnApiVersion
LOCAL lcAssignmentRuleId
LOCAL lcConcurrencyMode
LOCAL lcContentType
LOCAL lcCreatedById
LOCAL lcCreatedDate
LOCAL lcExternalIdFieldName
LOCAL lnFastPathEnabled
LOCAL lcId
LOCAL lnNumberBatchesCompleted
LOCAL lnNumberBatchesFailed
LOCAL lnNumberBatchesInProgress
LOCAL lnNumberBatchesQueued
LOCAL lnNumberBatchesTotal
LOCAL lnNumberRecordsFailed
LOCAL lnNumberRecordsProcessed
LOCAL lnNumberRetries
LOCAL lcV_object
LOCAL lcOperation
LOCAL lcState
LOCAL lcSystemModstamp
LOCAL lnTotalProcessingTime
* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
loHttp = CreateObject('Chilkat.Http')
* Use this online tool to generate code from sample JSON: Generate Code to Create JSON
* The following JSON is sent in the request body.
* {
* "state": "Closed"
* }
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateString("state","Closed")
loHttp.SetRequestHeader("Content-Type","application/json")
loHttp.SetRequestHeader("X-SFDC-Session","{{_accessToken}}")
loHttp.SetRequestHeader("Accept-Encoding","gzip")
* Adds the "Authorization: Bearer <access_token>" header.
loHttp.AuthToken = "<access_token>"
loHttp.SetRequestHeader("charset","UTF-8")
loHttp.SetRequestHeader("Content-Encoding","gzip")
loResp = loHttp.PostJson3("https://domain.com/services/async/{{version}}/job/{{_jobId}}","application/json",loJson)
IF (loHttp.LastMethodSuccess = 0) THEN
? loHttp.LastErrorText
RELEASE loHttp
RELEASE loJson
CANCEL
ENDIF
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbResponseBody = CreateObject('Chilkat.StringBuilder')
loResp.GetBodySb(loSbResponseBody)
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJResp = CreateObject('Chilkat.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0
? "Response Body:"
? loJResp.Emit()
lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
? "Response Header:"
? loResp.Header
? "Failed."
RELEASE loResp
RELEASE loHttp
RELEASE loJson
RELEASE loSbResponseBody
RELEASE loJResp
CANCEL
ENDIF
RELEASE loResp
* Sample JSON response:
* (Sample code for parsing the JSON response is shown below)
* {
* "apexProcessingTime": 64,
* "apiActiveProcessingTime": 225,
* "apiVersion": 58,
* "assignmentRuleId": null,
* "concurrencyMode": "Parallel",
* "contentType": "CSV",
* "createdById": "005...",
* "createdDate": "<date_time>",
* "externalIdFieldName": null,
* "fastPathEnabled": false,
* "id": "750...",
* "numberBatchesCompleted": 1,
* "numberBatchesFailed": 0,
* "numberBatchesInProgress": 0,
* "numberBatchesQueued": 0,
* "numberBatchesTotal": 1,
* "numberRecordsFailed": 0,
* "numberRecordsProcessed": 1,
* "numberRetries": 0,
* "object": "<Object>",
* "operation": "insert",
* "state": "Closed",
* "systemModstamp": "<date_time>",
* "totalProcessingTime": 403
* }
* Sample code for parsing the JSON response...
* Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
lnApexProcessingTime = loJResp.IntOf("apexProcessingTime")
lnApiActiveProcessingTime = loJResp.IntOf("apiActiveProcessingTime")
lnApiVersion = loJResp.IntOf("apiVersion")
lcAssignmentRuleId = loJResp.StringOf("assignmentRuleId")
lcConcurrencyMode = loJResp.StringOf("concurrencyMode")
lcContentType = loJResp.StringOf("contentType")
lcCreatedById = loJResp.StringOf("createdById")
lcCreatedDate = loJResp.StringOf("createdDate")
lcExternalIdFieldName = loJResp.StringOf("externalIdFieldName")
lnFastPathEnabled = loJResp.BoolOf("fastPathEnabled")
lcId = loJResp.StringOf("id")
lnNumberBatchesCompleted = loJResp.IntOf("numberBatchesCompleted")
lnNumberBatchesFailed = loJResp.IntOf("numberBatchesFailed")
lnNumberBatchesInProgress = loJResp.IntOf("numberBatchesInProgress")
lnNumberBatchesQueued = loJResp.IntOf("numberBatchesQueued")
lnNumberBatchesTotal = loJResp.IntOf("numberBatchesTotal")
lnNumberRecordsFailed = loJResp.IntOf("numberRecordsFailed")
lnNumberRecordsProcessed = loJResp.IntOf("numberRecordsProcessed")
lnNumberRetries = loJResp.IntOf("numberRetries")
lcV_object = loJResp.StringOf("object")
lcOperation = loJResp.StringOf("operation")
lcState = loJResp.StringOf("state")
lcSystemModstamp = loJResp.StringOf("systemModstamp")
lnTotalProcessingTime = loJResp.IntOf("totalProcessingTime")
RELEASE loHttp
RELEASE loJson
RELEASE loSbResponseBody
RELEASE loJResp
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-H "X-SFDC-Session: {{_accessToken}}"
-H "Content-Type: application/json"
-H "charset: UTF-8"
-H "Accept-Encoding: gzip"
-H "Content-Encoding: gzip"
-d '{
"state" : "Closed"
}'
https://domain.com/services/async/{{version}}/job/{{_jobId}}
Postman Collection Item JSON
{
"name": "Bulk Close Job",
"request": {
"method": "POST",
"header": [
{
"key": "X-SFDC-Session",
"value": "{{_accessToken}}"
},
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "charset",
"value": "UTF-8"
},
{
"key": "Accept-Encoding",
"value": "gzip",
"disabled": true
},
{
"key": "Content-Encoding",
"value": "gzip",
"disabled": true
}
],
"body": {
"mode": "raw",
"raw": "{\n \"state\" : \"Closed\"\n}"
},
"url": {
"raw": "{{_endpoint}}/services/async/{{version}}/job/{{_jobId}}",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"async",
"{{version}}",
"job",
"{{_jobId}}"
]
}
},
"response": [
{
"name": "Successful Bulk Close Job",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "X-SFDC-Session",
"value": "{{_accessToken}}"
},
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "charset",
"value": "UTF-8"
},
{
"key": "Accept-Encoding",
"value": "gzip",
"disabled": true
},
{
"key": "Content-Encoding",
"value": "gzip",
"disabled": true
}
],
"body": {
"mode": "raw",
"raw": "{\n \"state\" : \"Closed\"\n}"
},
"url": {
"raw": "{{_endpoint}}/services/async/{{version}}/job/{{_jobId}}",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"async",
"{{version}}",
"job",
"{{_jobId}}"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Thu, 16 Nov 2023 16:23:52 GMT"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=63072000; includeSubDomains"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "X-Robots-Tag",
"value": "none"
},
{
"key": "Cache-Control",
"value": "no-cache,must-revalidate,max-age=0,no-store,private"
},
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Content-Encoding",
"value": "gzip"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
}
],
"cookie": [
],
"body": "{\n \"apexProcessingTime\": 64,\n \"apiActiveProcessingTime\": 225,\n \"apiVersion\": 58,\n \"assignmentRuleId\": null,\n \"concurrencyMode\": \"Parallel\",\n \"contentType\": \"CSV\",\n \"createdById\": \"005...\",\n \"createdDate\": \"<date_time>\",\n \"externalIdFieldName\": null,\n \"fastPathEnabled\": false,\n \"id\": \"750...\",\n \"numberBatchesCompleted\": 1,\n \"numberBatchesFailed\": 0,\n \"numberBatchesInProgress\": 0,\n \"numberBatchesQueued\": 0,\n \"numberBatchesTotal\": 1,\n \"numberRecordsFailed\": 0,\n \"numberRecordsProcessed\": 1,\n \"numberRetries\": 0,\n \"object\": \"<Object>\",\n \"operation\": \"insert\",\n \"state\": \"Closed\",\n \"systemModstamp\": \"<date_time>\",\n \"totalProcessingTime\": 403\n}"
}
]
}