SAP Knowledge Base Article - Public

3709239 - SF Odata API $batch rollback logic

Symptom

When we using $batch to upsert SF entity, sometimes the data will be rolled back with failed, and sometimes it will succeed partially.

Image/data in this KBA is from SAP internal systems, sample data, or demo systems. Any resemblance to real data is purely coincidental.

Environment

  • SAP SuccessFactors HXM Suite
    • OData API $batch

Cause

$batch request is based on the changeset, each changeset is a complete unit. 

If there is a failure during data upsert with the same changeset, the entire changeset will be rolled back.

Resolution

1. If we use the different changeset, changeset_0001 is a failure while changeset_0002 is a success.

POST: {{URLTest}}$batch
Payload:

--batch_AAATMA
Content-Type: multipart/mixed; boundary=changeset_0001

--changeset_0001
Content-Type: application/http
Content-Transfer-Encoding: binary

POST upsert?$format=json HTTP/1.1
Content-Length: 299
content-type: application/json

{"customDate31":"/Date(1769936400000)/","eventReason":"DATACHG","userId":"17421500","startDate":"/Date(1769936400000)/","__metadata":{"uri":"EmpJob"}}
--changeset_0001--
--batch_AAATMA
Content-Type: multipart/mixed; boundary=changeset_0002

--changeset_0002
Content-Type: application/http
Content-Transfer-Encoding: binary

POST upsert?$format=json HTTP/1.1
Content-Length: 297
content-type: application/json

{"eventReason":"DATACHG","userId":"108743","startDate":"/Date(1769936400000)/","__metadata":{"uri":"EmpCompensation"}}
--changeset_0002--
--batch_AAATMA--

 

Response:

--batch_90a1ae64-c95c-49eb-98e3-742b616609ac
Content-Type: application/http
Content-Transfer-Encoding: binary

HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=utf-8
DataServiceVersion: 1.0
X-SF-Record-Count-Recursive: 0
successfactors-message: successfactors-sourcetype is missing in request headers
Content-Length: 160

{
"error" : {
"code" : "COE_GENERAL_BAD_REQUEST", "message" : {
"lang" : "en-US", "value" : "ChangeSet index 1 - unknown property customDate31 for EmpJob"
}
}
}

--batch_90a1ae64-c95c-49eb-98e3-742b616609ac
Content-Type: multipart/mixed; boundary=changeset_4fca534f-ec9f-4f32-82b9-20e9cd9fdeed

--changeset_4fca534f-ec9f-4f32-82b9-20e9cd9fdeed
Content-Type: application/http
Content-Transfer-Encoding: binary

HTTP/1.1 200 OK
Content-Type: application/json;charset=utf-8
DataServiceVersion: 1.0
successfactors-message: successfactors-sourcetype is missing in request headers
Content-Length: 326

{
"d" : [
{
"key" : "EmpCompensation/startDate=2026-02-01T09:00:00.000Z,EmpCompensation/userId=108743", "status" : "OK", "editStatus" : "UPSERTED", "message" : "[Warning!] This record was not saved because there were no new changes compared to the existing record.", "index" : 0, "httpCode" : 200, "inlineResults" : null
}
]
}

--changeset_4fca534f-ec9f-4f32-82b9-20e9cd9fdeed--

--batch_90a1ae64-c95c-49eb-98e3-742b616609ac--

2. If we use the same changeset, all upsert records are failed (Even if only the first record/second record fails to upsert).
POST: {{URLTest}}$batch
Payload:

--batch_AAATMA
Content-Type: multipart/mixed; boundary=changeset_0001

--changeset_0001
Content-Type: application/http
Content-Transfer-Encoding: binary

POST upsert?$format=json HTTP/1.1
Content-Length: 299
content-type: application/json

{"customDate31":"/Date(1769936400000)/","eventReason":"DATACHG","userId":"17421500","startDate":"/Date(1769936400000)/","__metadata":{"uri":"EmpJob"}}

--changeset_0001
Content-Type: application/http
Content-Transfer-Encoding: binary

POST upsert?$format=json HTTP/1.1
Content-Length: 297
content-type: application/json

{"eventReason":"DATACHG","userId":"108743","startDate":"/Date(1769936400000)/","__metadata":{"uri":"EmpCompensation"}}
--changeset_0001--
--batch_AAATMA--

Response:

--batch_c3f1a0ca-695c-41ed-b5eb-9ff63f6a9574
Content-Type: application/http
Content-Transfer-Encoding: binary

HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=utf-8
DataServiceVersion: 1.0
X-SF-Record-Count-Recursive: 0
successfactors-message: successfactors-sourcetype is missing in request headers
Content-Length: 160

{
"error" : {
"code" : "COE_GENERAL_BAD_REQUEST", "message" : {
"lang" : "en-US", "value" : "ChangeSet index 1 - unknown property customDate31 for EmpJob"
}
}
}

--batch_c3f1a0ca-695c-41ed-b5eb-9ff63f6a9574--

 

Keywords

batch operation, rollback issue, changeset integrity, data rollback, batch processing , KBA , LOD-SF-INT-ODATA , OData API Framework , Problem

Product

SAP SuccessFactors Platform all versions