Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

A JSON number is not supported as Edm.Decimal value

premchander
Explorer

Hi,

I have an issue in ODATA 2.0 payload POST request when I try to send decimal value as below,

POST servicName/books

{

"Name": "Scarlet",

"Price": "25.50"

}

error which i am getting is,

{
“error”: {
“code”: null,
“message”: “Error while deserializing payload. An error occurred during deserialization of the entity. A JSON number is not supported as Edm.Decimal value.”
}
}

Price is of type Price: Decimal(13, 3);

Note: I have been using CAP CDS NodeJs for ODATA

Could you please help me how to insert decimal value with ODATA on request payload via json?

1 ACCEPTED SOLUTION

former_member235482
Participant

Not sure about oData 2.0 but For oData 4.0 Post: http://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html#sec_PrimitiveV...

Add `IEEE754Compatible=true` to the Content-Type Header

7 REPLIES 7

former_member370623
Active Participant

Hi Prem ,

you are sending 25.50 as string not number try sending without quotes

"Name": "Scarlet"

"Price": 25.50

0 Kudos

Hi Ibrahim,

I have tried as you mentioned. Still I am getting the same error. I have also tried as below

Scenario 1:

"Name": "Scarlet"

"Price": 25.50

Scenario 2:

"Name": "Scarlet"

"Price": "25.50M"

But none of the above working for me when i send the request.

0 Kudos

can you try with ',' instead of dot something like 25,50

Did not work.

former_member663054
Discoverer
0 Kudos

I'm having the same problem given this CDS Data model:

entity FinancedItemsPayments_001{
	key ID			: UUID;
	financedItem		: Association to FinancedItems_001;
	secuence		: Integer;
	flagDel			: Boolean;
	datePro			: Date;
	datePay			: Date;
	payAmt			: Decimal ( 13, 2);

[...]
}

Raw JSON Request:

{
    "secuence": 1,
    "flagDel": false,
    "datePro": "2020-02-26",
    "datePay": "2020-02-26",
    "payAmt": "2.00",
    "financedItem_ID": "bc9ed4ca-cd8b-419d-a36e-ebb189a9572a",
[...}
}

Response:

{
    "error": {
        "code": null,
        "message": "Error while deserializing payload. An error occurred during deserialization of the entity. A JSON number is not supported as Edm.Decimal value."
    }
}


former_member235482
Participant

Not sure about oData 2.0 but For oData 4.0 Post: http://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html#sec_PrimitiveV...

Add `IEEE754Compatible=true` to the Content-Type Header

venkateswaran_k
Active Contributor

Dear Prem

Since in your mode - you are using Price is of type Price: Decimal(13, 3);

Decimal position as 3

make sure you pass 3 decimals

I faced similar issue, if my user did not put decimals - request got failed due to this decimal notation error.

Regards,

Venkat