cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

S4HANA Public Cloud - CBO Upsert Error 'Expected type is 'Edm.Boolean''

RWeidner
Explorer
0 Kudos
262

Hi all,

I'm trying an upsert to a custom CBO but the expected types are sort of strange.

 

It does not accept the values a GET request response.
Also numeric is not accepted as '1.00' but 1.00m

Example for the error:

https://xxxx/sap/opu/odata/sap/YY1_API_TEST_CDS/YY1_API_TESTSap_upsert?NumericID='0000000001'&SAP_De...

CheckBox = true is not considered as boolean, nor is 'true' or 'X' or 1 or whatever.

Has anyone solved this?

Accepted Solutions (0)

Answers (1)

Answers (1)

Chuma
Active Contributor
0 Kudos

Hello @RWeidner 

Your call is failing because the CBO sap_upsert must be invoked with POST and a JSON body, not by passing parameters in the URL. When you include parameters in the query string, the gateway treats them as strings, leading to the error Expected type is Edm.Boolean.

What to do (works reliably in Public Cloud):

Call the function import with POST + JSON

POST /sap/opu/odata/sap/YY1_API_TEST_CDS/YY1_API_TESTSap_upsert

Content-Type: application/json

Accept: application/json

{

  "NumericID": "0000000001",

  "CheckBox": true,

  "Amount": 1.00

}

  • CheckBox must be a JSON boolean: true or false (no quotes).
  • Decimals can be sent as numbers in JSON; the service will type them as Edm. Decimal from metadata. SAP Help Portal

If you only want to quick-test via URL (GET)

  • Use OData V2 literal rules:
    • Boolean: CheckBox=true (lowercase, no quotes)
    • Decimal: add the M suffix, e.g. Amount=1.00M
      Example:

.../YY1_API_TEST_CDS/YY1_API_TESTSap_upsert?

  NumericID='0000000001'&CheckBox=true&Amount=1.00M

Double-check names and types in $metadata
Open the service $metadata and verify the FunctionImport parameter names and EDM types match what you send. If the parameter name differs from the entity field name, you must use the function import’s parameter name. odata.org-Operations (OData Version 2.0)

With kind regards

Chuma