SAP Knowledge Base Article - Public

2658508 - OData Error: Illegal JSON string-value format while executing an UPSERT operation on an ODATA Entity

Symptom

The following error occurred while executing an UPSERT operation on an ODATA Entity:

<d:message>Illegal JSON string-value format</d:message>

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

Reproducing the Issue

1. Send an UPSERT API Call (For example: Upsert API Call for ODATA API Entity Background_Education)

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

    Request Body:

    [
            {
                "__metadata": {
                    "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/Background_Education(backgroundElementId=100L,userId='pjuvan1')",
                    "type": "SFOData.Background_Education"
                },
                "backgroundElementId": "100",
                "userId": "pjuvan1",
                "startDate": null,
                "bgOrderPos": "1",
                "school": "true",
                "degree": 216,
                "StillAttending": null,
                "endDate": null,
                "major": "99"
    
           }
    ]

2. The response has the below error:

    <d:status>ERROR</d:status>
    <d:editStatus>UPSERTED</d:editStatus>
    <d:message>Illegal JSON string-value format</d:message>

Cause

The request payload is not in the correct JSON format.

Resolution

1. All the input values needs to be passed in double quotes (" ")

2. Re-run the Upsert API Call (For example: In the above erroneous payload the value for the field degree i.e. 216 was not passed in double quotes. Correct the request payload by passing the input value in double quotes and re-run the upsert API call for the sample ODATA entity: Background_Education)

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

    Request Body:

    [
            {
                "__metadata": {
                    "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/Background_Education(backgroundElementId=100L,userId='pjuvan1')",
                    "type": "SFOData.Background_Education"
                },
                "backgroundElementId": "100",
                "userId": "pjuvan1",
                "startDate": null,
                "bgOrderPos": "1",
                "school": "true",
                "degree": "216",
                "StillAttending": null,
                "endDate": null,
                "major": "99"
    
           }
    ]

3. The upsert call will be successful and the data would be upserted in the system. Response will be like below:

   <d:status>OK</d:status>

Keywords

Illegal JSON string-value format, UPSERT, operation, double quote, JSON, error, OData, POST , KBA , LOD-SF-INT-ODATA , OData API Framework , LOD-SF-INT , Integrations , LOD-SF-INT-EC , Employee Central SFAPI & OData Entities , Problem

Product

SAP SuccessFactors HCM Core 2511