Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Primitive values of type 'Edm.Decimal' and 'Edm.Int64' must be quoted in the payload. Make sure the value is quoted. #54

Open
tomaswitek opened this issue May 5, 2014 · 4 comments

Comments

@tomaswitek
Copy link

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)&#13;
   at Microsoft.Data.OData.JsonLight.ODataJsonLightPropertyAndValueDeserializer.ReadPrimitiveValue(Boolean insideJsonObjectValue, IEdmPrimitiveTypeReference expectedValueTypeReference, Boolean validateNullValue)&#13;
   at Microsoft.Data.OData.JsonLight.ODataJsonLightPropertyAndValueDeserializer.ReadNonEntityValueImplementation(String payloadTypeName, IEdmTypeReference expectedTypeReference, DuplicatePropertyNamesChecker duplicatePropertyNamesChecker, CollectionWithoutExpectedTypeValidator collectionValidator, Boolean validateNullValue, Boolean isTopLevelPropertyValue, Boolean insideComplexValue)&#13;
   at Microsoft.Data.OData.JsonLight.ODataJsonLightEntryAndFeedDeserializer.ReadEntryDataProperty(IODataJsonLightReaderEntryState entryState, IEdmProperty edmProperty, String propertyTypeName)&#13;
   at Microsoft.Data.OData.JsonLight.ODataJsonLightEntryAndFeedDeserializer.ReadEntryPropertyWithValue(IODataJsonLightReaderEntryState entryState, String propertyName)&#13;
   at Microsoft.Data.OData.JsonLight.ODataJsonLightEntryAndFeedDeserializer.&lt;&gt;c__DisplayClass2.&lt;ReadEntryContent&gt;b__0(PropertyParsingResult propertyParsingResult, String propertyName)&#13;
   at Microsoft.Data.OData.JsonLight.ODataJsonLightDeserializer.ProcessProperty(DuplicatePropertyNamesChecker duplicatePropertyNamesChecker, Func`2 readPropertyAnnotationValue, Action`2 handleProperty)&#13;
   at Microsoft.Data.OData.JsonLight.ODataJsonLightEntryAndFeedDeserializer.ReadEntryContent(IODataJsonLightReaderEntryState entryState)&#13;
   at Microsoft.Data.OData.JsonLight.ODataJsonLightReader.ReadAtEntryStartImplementationSynchronously()&#13;
   at Microsoft.Data.OData.ODataReaderCore.ReadImplementation()&#13;
   at Microsoft.Data.OData.ODataReaderCore.InterceptException[T](Func`1 action)&#13;
   at System.Data.Services.Serializers.EntityDeserializer.ReadEntry(ODataReader odataReader, SegmentInfo topLevelSegmentInfo)&#13;
   at System.Data.Services.Serializers.EntityDeserializer.Read(SegmentInfo segmentInfo)&#13;
   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)&#13;
   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
Copy link
Author

Here you can find service metadata:
https://app.idoklad.cz/odataservice.svc/$metadata
Thx

@visoft
Copy link
Owner

visoft commented May 6, 2014

Did you try self.Price = "500.00"

@tomaswitek
Copy link
Author

I found the problem:

self.Price = "500"
self.Amount = "5"

These variables have to be quoted.
Thx

@richardrails
Copy link

+1 for REST API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants