SAP Knowledge Base Article - Public

3386305 - Odata API: "Unknown content type application/xml" error message is displayed after upserting XML format data

Symptom

"Unknown content type application/xml" error message is displayed after upserting XML format data.

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

  • SF OData API

Reproducing the Issue

Post: odata/v2/upsert

Payload example:

<?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://api2.successfactors.eu/odata/v2/">
    <id>https://apisalesdemo8.successfactors.com/odata/v2/PerEmail</id>
    <title type="text">PerEmail</title>
    <updated>2022-04-13T10:23:26.804Z</updated>
    <author>
        <name/>
    </author>
    <link href="PerEmail" rel="self" title="PerEmail"/>
    <entry>
        <id>https://apisalesdemo8.successfactors.com/odata/v2/PerEmail</id>
        <title type="text">PerEmail</title>
        <updated>2022-04-13T10:23:26.804Z</updated>
        <category term="SFOData.PerEmail" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
        <link href="PerEmail" rel="edit" title="PerEmail"/>
        <content type="application/xml">
            <m:properties>
                <d:emailAddress>test123@163.com</d:emailAddress>
                <d:isPrimary>true</d:isPrimary>
                <d:personIdExternal>tadmin</d:personIdExternal>
                <d:emailType>8447</d:emailType>
            </m:properties>
        </content>
    </entry>
     <entry>
        <id>https://apisalesdemo8.successfactors.com/odata/v2/PerEmail</id>
        <title type="text">PerEmail</title>
        <updated>2022-04-13T10:23:26.804Z</updated>
        <category term="SFOData.PerEmail" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
        <link href="PerEmail" rel="edit" title="PerEmail"/>
        <content type="application/xml">
            <m:properties>
                <d:emailAddress>test123@qq.com</d:emailAddress>
                <d:isPrimary>false</d:isPrimary>
                <d:personIdExternal>SFADMIN</d:personIdExternal>
                <d:emailType>8447</d:emailType>
            </m:properties>
        </content>
    </entry>
</feed>
 
Response:
 
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
    <code>BadRequestException</code>
    <message lang="en-US">Unknown content type application/xml</message>
</error>
 
Screenshot is below:

Cause

Incorrect Content-Type value in the header:

Resolution

Please use 'application/atom+xml;charset=utf-8' in the field 'Content-Type':

Upsert Results:

Keywords

OData API, Unknown content type application/xml, XML, upsert, application/xml, application/atom+xml;charset=utf-8 , KBA , LOD-SF-INT-ODATA , OData API Framework , Problem

Product

SAP SuccessFactors HXM Core 2305

Attachments

Pasted image.png
Pasted image.png