SAP Knowledge Base Article - Public

2942505 - XXX is a required field and cannot be blank : error is getting thrown during EmpJob OData API Upsert

Symptom

While creating/updating a record of a user using OData UPSERT operation, API server throws following error:

XXX is a required field and cannot be blank

              

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 Employee Central OData API

Reproducing the Issue

To reproduce the issue, let's create a new hire job information record.

Please execute the following request payload in POSTMAN

POST: https://apisalesdemo4.successfactors.com/odata/v2/upsert

{
"__metadata": {
"uri": "https://apisalesdemo4.successfactors.com/odata/v2/EmpJob",
"type": "SFOData.EmpJob"
},
"businessUnit": "PRODS",
"company": "8500",
"payScaleType": "AUS/AUQ1",
"eventReason": "HIRNEW",
"jobTitle": null,
"location": "8510-0001",
"startDate": "/Date(1593525511000)/",
"timezone": "Australia/Sydney",
"userId": "roht1",
"managerId": "NO_MANAGER"
}



API will throw the below error:



<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
<entry>
<content type="application/xml">
<m:properties>
<d:key>EmpJob/seqNumber=null,EmpJob/startDate=2020-06-30T13:58:31.000-04:00,EmpJob/userId=roht1</d:key>
<d:status>ERROR</d:status>
<d:editStatus m:null="true"></d:editStatus>
<d:message>job-title is a required field and cannot be blank.
Failed record info: {EmpJob/businessUnit=PRODS, EmpJob/company=8500, EmpJob/payScaleType=AUS/AUQ1, EmpJob/eventReason=HIRNEW, EmpJob/jobTitle=null, EmpJob/location=8510-0001, EmpJob/startDate=2020-06-30T13:58:31.000-04:00, EmpJob/timezone=Australia/Sydney, EmpJob/userId=roht1, EmpJob/managerId=NO_MANAGER}.
for Key EmpJob/seqNumber=null,EmpJob/startDate=2020-06-30T13:58:31.000-04:00,EmpJob/userId=roht1 with the index 0</d:message>
<d:index m:type="Edm.Int32">0</d:index>
<d:httpCode m:type="Edm.Int32">500</d:httpCode>
<d:inlineResults m:type="Bag(SFOData.UpsertResult)"></d:inlineResults>
</m:properties>
</content>
</entry>
</feed>

Cause

The null value has been passed in the OData API payload for a required field which has Nullable attribute value true.

"fieldName": null

Like in example

"jobTitle": null,

Resolution

If a required field attribute Nullable is true then null value to the field is passed in OData API call as

"fieldName": "null"

Let's correct the example as

POST: https://apisalesdemo4.successfactors.com/odata/v2/upsert

{
"__metadata": {
"uri": "https://apisalesdemo4.successfactors.com/odata/v2/EmpJob",
"type": "SFOData.EmpJob"
},
"businessUnit": "PRODS",
"company": "8500",
"payScaleType": "AUS/AUQ1",
"eventReason": "HIRNEW",
"jobTitle": "null",
"location": "8510-0001",
"startDate": "/Date(1593525511000)/",
"timezone": "Australia/Sydney",
"userId": "roht1",
"managerId": "NO_MANAGER"
}

See Also

Please refer the guide for Employee Central OData API etities.

Keywords

UPSERT, null, OData, EmpJob, ERROR , KBA , LOD-SF-INT-EC , Employee Central SFAPI & OData Entities , LOD-SF-INT , Integrations , Problem

Product

SAP SuccessFactors HXM Core 2005