SAP Knowledge Base Article - Public

2481513 - OData API 'Required field with index 0' error while upserting

Symptom

When performing the upsert operation to update single field, getting required field error in the response:

<?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 m:null="true"></d:key>

                <d:status>ERROR</d:status>

                <d:editStatus m:null="true"></d:editStatus>

                <d:message>date1 required for external candidate, date2 required for external candidate, country required for external candidate, for templateId 123,  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>

Environment

SuccessFactors BizX  - Recruiting Management(RCM)

Reproducing the Issue

You are performing a upsert operation to update single field 'Id' of the application. This is just an example.

1. Use an of the method  to perform upsert operation.

2. I am using POSTMAN

3. Insert the url: “https://api4.successfactors.com/odata/v2/upsert” (this url should be based on your instance data center)

4. Provide API username and password

5. Insert the xml code 

<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"

 xml:base="https://api4.successfactors.com:443/odata/v2/">          

                    <entry>

                                        <id>https://api4.successfactors.com:443/odata/v2/JobApplication(123L)</id>

                                        <content type="application/xml">

                                                            <m:properties>

                                                                                <d:comentIdCreation>[Test 45]Id has been requested</d:comentIdCreation>

                                                            </m:properties>

                                        </content>

                    </entry>

</feed>

6. Run the upsert query

7. You get a below response:

<?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 m:null="true"></d:key>

                <d:status>ERROR</d:status>

                <d:editStatus m:null="true"></d:editStatus>

                <d:message>date1 required for external candidate, date2 required for external candidate, country required for external candidate, for templateId 123,  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

We are just passing the value/data for a single field which we want to update.

Resolution

When we are using upsert operation, it is required/mandatory to pass value/data for all the required fields of the template even if we just want to update a single field.

In the given example, I just wanted to update the field Id from application template. Hence, just passed data for Id field in the Request as [Test 45 ]. However, in the application template, there are other required fields present. We need to make sure, data should be passed for all required fields in order to just update single field. 

Keywords

OData API Upsert operation Upsert Required field with index error , KBA , LOD-SF-RCM-API , Webservices & APIs , Problem

Product

SAP SuccessFactors HCM Core 1702