SAP Knowledge Base Article - Public

2856755 - Odata API Upsert Error :BadRequestException >The post data are in the bad JSON format: Unexpected

Symptom

When doing Odata API Upsert via JSON payload format, you encounter Odata API Errors response describe in below exception message samples.

Image/data in this KBA is from SAP internal systems, sample data, or demo systems. Any resemblance to real data is purely coincidental.

Sample Error 1 (2 error message type in this category)

  • <code>BadRequestException</code>
    <messagelang="en-US">
    The post data are in the bad JSON format: Unexpected end-of-input: (1) expected close marker for Object (start marker at  or (2) within/between Object entries [Source: (String) >Request Payload Body with BAD FORMAT Is shown in here in the message Exception/API Response<)</message>

SE2.jpg

Sample Error 2

  • <code>BadRequestException</code>
    <messagelang="en-US">The post data are in the bad JSON format: Unexpected character (''' (code 39)): expected a valid value (number, String, array, object, 'true', 'false' or 'null’) at [Source: (String) >Request Payload with BAD FORMAT Is shown in here in the message Exception/API Response<)</message>

SE1.jpg

Environment

Successfactors HCM Suite

Reproducing the Issue

1. Perform Upsert via Odata API with JSON format request payload

2. See Error of Bad Request or Bad JSON format Exception Message

Cause

Sample Error 1 : Missing closing brackets (check the format beginning, middle and end of the request payload)

Sample Error 2 : Incorrect usage of quotation (in the example, single quote ( ' ) was used for a string field, hence the error.

Resolution

For Sample Error 1 : The request payload body should have '}' closing brackets at the end. This error could also happen

For Sample Error 2 : Replace the single quote '44' with "44" since the field is a string field. Check Odata API data dictionary to verify the field type of the field being upserted. (note : for boolean field type only 'true' or 'false' is accepted.)

Additional : You can check first your request payload format using any JSON formatting checker prior sending for API Edit operations (any standard and preferred Online/Offline JSON Formatter check tool)

See Also

See SAP SuccessFactors HCM Suite OData API: Developer Guide for more info on Query / Edit operations

Keywords

HTTP Response = 400, The post data are in the bad JSON format: Unexpected end-of-input, The post data are in the bad JSON format: Unexpected character, BadRequestException, Odata API Upsert Error, SuccessFactors HCM suite , KBA , LOD-SF-INT-ODATA , OData API Framework , LOD-SF-INT , Integrations , Problem

Product

SAP SuccessFactors HCM suite all versions