SAP Knowledge Base Article - Public

2295394 - Getting a '400 Bad Request' error message for an Odata API call when used inside the Java code

Symptom

While querying the Odata API Entity inside a Java(custom) code, receiving '400 Bad Request' error message in response.

The query is a simple one like below:

odata/v2/<EntityName>?$filt​er=<field1> eq %27<value1>%27 and <field2> ne %27<value2>%27

Environment

Successfactors BizX

Reproducing the Issue

NA

Cause

While building the query, the third party tool(or Java code in this case) turned spaces into '+' symbol which resulted in the 'Bad request' error message because '+' symbol is not understood by our APIs.

For example, below query when passed from a third party tool or written inside a Java code

odata/v2/<EntityName>?$filt​er=<field1> eq %27<value1>%27 and <field2> ne %27<value2>%27

will turn into below when sent to the API-

odata/v2/<EntityName>?$filt​er=<field1>+eq+%27<value1>%27+and+<field2>+ne+%27<value2>%27

Resolution

Need to replace the space in the query with '%20' and the issue will be resolved.

odata/v2/<EntityName>?$filt​er=<field1>%20eq%20%27<value1>%27%20and%20<field2>%20ne%20%27<value2>%27

See Also

http://help.sap.com/saphelpiis_cloud4hr/EN/SF_HCMS_OData_API_User_en/default.html?03e1fc3791684367a6a76a614a2916de.html

Keywords

400 Bad Request Odata query failing in Java code , KBA , LOD-SF-INT-API , API & Adhoc API Framework , LOD-SF-INT , Integrations , Problem

Product

SAP SuccessFactors HCM suite all versions