Primitive values of type 'Edm.Decimal' and 'Edm.Int64' must be quoted in the payload. Make sure the value is quoted.
tomaswitek opened this issue · 4 comments
tomaswitek commented
Hi,
I am trying to create entity, but I am getting exceptions about Edm.Decimal.
I think the problem is the Price attribute.
I have tried almost everything:
self.Price = BigDecimal(500)
self.Price = 500
self.Price = "500"
module Idoklad
class IssuedInvoiceItem < Entity
attr_accessor :InvoiceId, :Name, :Amount, :Unit, :Price, :PriceType, :VatRateType
def initialize(item)
self.Price = BigDecimal(500)
self.Name = "HP tiskarna"
self.Amount = 5
self.PriceType = 1
self.Unit = "Kus"
self.VatRateType = 1
end
end
end
I am still getting this error:
<?xml version="1.0" encoding="utf-8"?>
<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code/>
<m:message xml:lang="en-US">An error occurred while processing this request.</m:message>
<m:innererror>
<m:message>Cannot convert a primitive value to the expected type 'Edm.Decimal'. See the inner exception for more details.</m:message>
<m:type>Microsoft.Data.OData.ODataException</m:type>
<m:stacktrace> at Microsoft.Data.OData.JsonLight.ODataJsonLightReaderUtils.ConvertValue(Object value, IEdmPrimitiveTypeReference primitiveTypeReference, ODataMessageReaderSettings messageReaderSettings, ODataVersion version, Boolean validateNullValue)
at Microsoft.Data.OData.JsonLight.ODataJsonLightPropertyAndValueDeserializer.ReadPrimitiveValue(Boolean insideJsonObjectValue, IEdmPrimitiveTypeReference expectedValueTypeReference, Boolean validateNullValue)
at Microsoft.Data.OData.JsonLight.ODataJsonLightPropertyAndValueDeserializer.ReadNonEntityValueImplementation(String payloadTypeName, IEdmTypeReference expectedTypeReference, DuplicatePropertyNamesChecker duplicatePropertyNamesChecker, CollectionWithoutExpectedTypeValidator collectionValidator, Boolean validateNullValue, Boolean isTopLevelPropertyValue, Boolean insideComplexValue)
at Microsoft.Data.OData.JsonLight.ODataJsonLightEntryAndFeedDeserializer.ReadEntryDataProperty(IODataJsonLightReaderEntryState entryState, IEdmProperty edmProperty, String propertyTypeName)
at Microsoft.Data.OData.JsonLight.ODataJsonLightEntryAndFeedDeserializer.ReadEntryPropertyWithValue(IODataJsonLightReaderEntryState entryState, String propertyName)
at Microsoft.Data.OData.JsonLight.ODataJsonLightEntryAndFeedDeserializer.<>c__DisplayClass2.<ReadEntryContent>b__0(PropertyParsingResult propertyParsingResult, String propertyName)
at Microsoft.Data.OData.JsonLight.ODataJsonLightDeserializer.ProcessProperty(DuplicatePropertyNamesChecker duplicatePropertyNamesChecker, Func`2 readPropertyAnnotationValue, Action`2 handleProperty)
at Microsoft.Data.OData.JsonLight.ODataJsonLightEntryAndFeedDeserializer.ReadEntryContent(IODataJsonLightReaderEntryState entryState)
at Microsoft.Data.OData.JsonLight.ODataJsonLightReader.ReadAtEntryStartImplementationSynchronously()
at Microsoft.Data.OData.ODataReaderCore.ReadImplementation()
at Microsoft.Data.OData.ODataReaderCore.InterceptException[T](Func`1 action)
at System.Data.Services.Serializers.EntityDeserializer.ReadEntry(ODataReader odataReader, SegmentInfo topLevelSegmentInfo)
at System.Data.Services.Serializers.EntityDeserializer.Read(SegmentInfo segmentInfo)
at System.Data.Services.Serializers.ODataMessageReaderDeserializer.Deserialize(SegmentInfo segmentInfo)</m:stacktrace>
<m:internalexception>
<m:message>Primitive values of type 'Edm.Decimal' and 'Edm.Int64' must be quoted in the payload. Make sure the value is quoted.</m:message>
<m:type>Microsoft.Data.OData.ODataException</m:type>
<m:stacktrace> at Microsoft.Data.OData.JsonLight.ODataJsonLightReaderUtils.ConvertInt32Value(Int32 intValue, Type targetType, IEdmPrimitiveTypeReference primitiveTypeReference)
at Microsoft.Data.OData.JsonLight.ODataJsonLightReaderUtils.ConvertValue(Object value, IEdmPrimitiveTypeReference primitiveTypeReference, ODataMessageReaderSettings messageReaderSettings, ODataVersion version, Boolean validateNullValue)</m:stacktrace>
</m:internalexception>
</m:innererror>
</m:error>
Any ideas?
Thx
tomaswitek commented
Here you can find service metadata:
https://app.idoklad.cz/odataservice.svc/$metadata
Thx
visoft commented
Did you try self.Price = "500.00"
tomaswitek commented
I found the problem:
self.Price = "500"
self.Amount = "5"
These variables have to be quoted.
Thx
richardrails commented
+1 for REST API