Symptom
You are receiving the error message below while trying to use a POST OData call to create an Employee in the EmployeeCollection.
400 Bad Request - The server could not understand the request due to malformed syntax.
Environment
SAP Cloud for Customer 2002 and higher.
Reproducing the Issue
- Go to the REST API Software (e.g Postman).
- Insert your credentials.
- Generate the CSRF Token.
- Use the payload below in the JSON-body.
{
"UserID":"Testing_Employee",
"EmployeeID":"12345",
"EmployeeValidityStartDate":"2020-02-20T15:49:48",
"EmployeeValidityEndDate":"9999-12-31T00:00:00",
"FirstName":"Testing",
"LastName":"Employee",
"UserValidityStartDate":"2020-02-20T15:49:48",
"UserValidityEndDate":"9999-12-31T00:00:00",
"UserPasswordPolicyCode":"S_BUSINESS_USER",
"CountryCode":"US",
"Email":"testing.employee@test.com",
"UserLockedIndicator":"false"
}
Cause
The error is occurring due to the quotation marks at the value for the "UserLockedIndicator". For Boolean values we don't use the quotation marks.
Resolution
You need to remove the quotation marks from the "UserLockedIndicator" attribute. Kindly use the payload as follows:
{
"UserID":"Testing_Employee",
"EmployeeID":"12345",
"EmployeeValidityStartDate":"2020-02-20T15:49:48",
"EmployeeValidityEndDate":"9999-12-31T00:00:00",
"FirstName":"Testing",
"LastName":"Employee",
"UserValidityStartDate":"2020-02-20T15:49:48",
"UserValidityEndDate":"9999-12-31T00:00:00",
"UserPasswordPolicyCode":"S_BUSINESS_USER",
"CountryCode":"US",
"Email":"testing.employee@test.com",
"UserLockedIndicator":false
}
Keywords
OData, Create, POST, EmployeeCollection, Error, 400 Bad Request. , KBA , AP-RC-ODF , OData framework (C4C Only) , How To