SAP Knowledge Base Article - Public

2976724 - How to upsert with association for Custom MDF Objects in SuccessFactors OData API (inline)

Symptom

You are trying to upsert records in parent/child entities using inline / associations of OData entities (like EC and MDF, MDF to MDF, etc).

This KBA will share samples of OData JSON and XML format with inline upserts (parent and child) in the same request payload.

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
  • SAP SuccessFactors Employee central
  • OData API

Resolution

Find below samples that you can use to build the same logic in your side.

Inline operation sample

JSON format

Request URL

  • /odata/v2/upsert?$format=json

Payload

{

                "__metadata": {

                    "uri": "cust_Contract(effectiveStartDate=datetime'2000-01-01T00:00:00',externalCode='372TD06A2F1_ST')",

                    "type": "SFOData.cust_Contract"

                },

                "externalCode": "372TD06A2F1_ST",

                "effectiveStartDate": "/Date(946684800000)/",

                "cust_VW": {

                            "__metadata": {

                                "uri": "cust_AmandaVW1(effectiveStartDate=datetime'2000-01-01T00:00:00',externalCode='vw5')",

                                "type": "SFOData.cust_AmandaVW1"

                            },

                            "externalCode": "vw5",

                            "effectiveStartDate": "/Date(946684800000)/"

                        }

            }

Response:

Atom format (XML)

Request URL

  • /odata/v2/upsert

Payload

<?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" xml:base="https://qaautocand-api.lab-rot.ondemand.com/odata/v2/">

    <title type="text">cust_Contract</title>

    <id>https://qaautocand-api.lab-rot.ondemand.com/odata/v2/cust_Contract</id>

    <updated>2020-09-08T11:22:54Z</updated>

    <link rel="self" title="cust_Contract" href="cust_Contract"></link>

    <entry>

        <id>https://qaautocand-api.lab-rot.ondemand.com/odata/v2/cust_Contract(effectiveStartDate=datetime'2000-01-01T00:00:00',externalCode='372TD06A2F1_ST')</id>

        <title type="text"></title>

        <updated>2020-09-08T11:22:54Z</updated>

        <author>

            <name></name>

        </author>

        <link rel="edit" title="cust_Contract" href="cust_Contract(effectiveStartDate=datetime'2000-01-01T00:00:00',externalCode='372TD06A2F1_ST')"></link>

        <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/cust_VW" type="application/atom+xml;type=feed" title="cust_VW" href="cust_AmandaVW1(effectiveStartDate=datetime'2000-01-01T00:00:00',externalCode='vw2')">

        </link>

        <category term="SFOData.cust_Contract" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"></category>

        <content type="application/xml">

            <m:properties>

                <d:externalCode>372TD06A2F1_ST</d:externalCode>

                <d:effectiveStartDate m:type="Edm.DateTime">2000-01-01T00:00:00</d:effectiveStartDate>

                <d:cust_description>Ray Whelton.</d:cust_description>

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

                <d:externalName>Ray Whelton.</d:externalName>

            </m:properties>

        </content>

    </entry>

</feed>

Response:

Record created in Atom/XML format too.

Please use the sample above to work with SF OData MDF, EC, and other entities using inline / parent/child upserts.

Keywords

inline, MDF, parent, child, upsert, OData, SuccessFactors HCM HXM Suite, API, navigation. JSON, XML, Atom, samples, custom objects , KBA , LOD-SF-INT , Integrations , LOD-SF-INT-ODATA , OData API Framework , LOD-SF-INT-MDF , Metadata Framework API (MDF) , LOD-SF-INT-EC , Employee Central SFAPI & OData Entities , How To

Product

SAP SuccessFactors Employee Central all versions ; SAP SuccessFactors HCM suite all versions