You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@olingo.apache.org by "Christian Amend (JIRA)" <ji...@apache.org> on 2017/09/11 08:25:01 UTC

[jira] [Resolved] (OLINGO-1108) Edm.Decimal not supported in OData Create requests (POST)

     [ https://issues.apache.org/jira/browse/OLINGO-1108?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Christian Amend resolved OLINGO-1108.
-------------------------------------
       Resolution: Not A Bug
         Assignee: Christian Amend
    Fix Version/s: V2 2.0.10

EDM.Decimal values must be Strings in a payload and not JSON Numbers according to the specification. So your client needs to be adjusted.

See: http://www.odata.org/documentation/odata-version-2-0/json-format/ 
Edm.Decimal	Literal form of Edm.Decimal as used in URIs formatted as a JSON string

> Edm.Decimal not supported in OData Create requests (POST)
> ---------------------------------------------------------
>
>                 Key: OLINGO-1108
>                 URL: https://issues.apache.org/jira/browse/OLINGO-1108
>             Project: Olingo
>          Issue Type: Bug
>          Components: odata2-core
>    Affects Versions: V2 2.0.8
>            Reporter: Patrick Haller
>            Assignee: Christian Amend
>             Fix For: V2 2.0.10
>
>
> We've got Edm.Decimal on a POST request (OData Create). 
> Upon sending the request, we see the following exception in the server log.
> In JsonPropertyConsumer.readSimpleProperty()'s switch case, we have
> type=Edm.Decimal
> tokenType=JsonToken.NUMBER
> and therefore end up with throwing INVALID_PROPERTY_VALUE.
> *exception*
> {quote}Caused by: org.apache.olingo.odata2.api.ep.EntityProviderException: Provided value for the property 'Quantity' is not compatible with the property.
> 	at org.apache.olingo.odata2.core.ep.consumer.JsonPropertyConsumer.readSimpleProperty(JsonPropertyConsumer.java:227)
> 	at org.apache.olingo.odata2.core.ep.consumer.JsonPropertyConsumer.readPropertyValue(JsonPropertyConsumer.java:169)
> 	at org.apache.olingo.odata2.core.ep.consumer.JsonEntryConsumer.handleName(JsonEntryConsumer.java:172)
> 	at org.apache.olingo.odata2.core.ep.consumer.JsonEntryConsumer.readEntryContent(JsonEntryConsumer.java:130)
> 	at org.apache.olingo.odata2.core.ep.consumer.JsonEntryConsumer.readSingleEntry(JsonEntryConsumer.java:93)
> 	at org.apache.olingo.odata2.core.ep.consumer.JsonEntityConsumer.readEntry(JsonEntityConsumer.java:57)
> 	at org.apache.olingo.odata2.core.ep.JsonEntityProvider.readEntry(JsonEntityProvider.java:315)
> 	at org.apache.olingo.odata2.core.ep.ProviderFacadeImpl.readEntry(ProviderFacadeImpl.java:179)
> 	at org.apache.olingo.odata2.api.ep.EntityProvider.readEntry(EntityProvider.java:746)
> 	at org.apache.olingo.odata2.jpa.processor.core.ODataEntityParser.parseEntry(ODataEntityParser.java:64)
> 	... 66 common frames omitted{quote}
> *Data Model classes*
> *Java Client (Spring RestTemplate)*
> {quote}class MyPostRequest {
>         @JsonProperty("Cost")
>         BigDecimal cost;
> }{quote}
> *Java Server (Olingo)*
> {quote}class ProjectCost implements Serializable
> {
>     // ...
>     @Column
>     private BigDecimal cost;
> }{quote}
> *$metadata*
> {quote}<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0">
> <edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="1.0">
> <Schema xmlns="http://schemas.microsoft.com/ado/2008/09/edm" Namespace="project">
> <EntityType xmlns:sap="http://www.sap.com/Protocols/SAPData" Name="Project" sap:label="Project">
> <Key>
> <PropertyRef Name="Uuid"/>
> </Key>
> <Property xmlns:sap="http://www.sap.com/Protocols/SAPData" Name="LastUpdate" Type="Edm.DateTime" Nullable="true" sap:label="Last Update"/>
> <Property xmlns:sap="http://www.sap.com/Protocols/SAPData" Name="Name" Type="Edm.String" Nullable="true" MaxLength="255" sap:label="Project"/>
> <Property xmlns:sap="http://www.sap.com/Protocols/SAPData" Name="ProjectType" Type="Edm.String" Nullable="true" MaxLength="255" sap:label="Type"/>
> <Property xmlns:sap="http://www.sap.com/Protocols/SAPData" Name="Responsible" Type="Edm.String" Nullable="true" MaxLength="255" sap:label="Person Responsible"/>
> <Property xmlns:sap="http://www.sap.com/Protocols/SAPData" Name="Stage" Type="Edm.String" Nullable="true" MaxLength="255" sap:label="Stage"/>
> <Property xmlns:sap="http://www.sap.com/Protocols/SAPData" Name="Status" Type="Edm.String" Nullable="true" MaxLength="255" sap:label="Status"/>
> <Property Name="Uuid" Type="Edm.String" Nullable="false"/>
> <NavigationProperty Name="ProjectCostDetails" Relationship="project.Project_ProjectCost_One_Many0" FromRole="Project" ToRole="ProjectCost"/>
> </EntityType>
> <EntityType Name="ProjectCost">
> <Key>
> <PropertyRef Name="Uuid"/>
> </Key>
> <Property Name="ChangedBy" Type="Edm.String" Nullable="true" MaxLength="255"/>
> <Property Name="ChangedTime" Type="Edm.DateTime" Nullable="true"/>
> <Property Name="Cost" Type="Edm.Decimal" Nullable="true"/>
> <Property Name="CreatedBy" Type="Edm.String" Nullable="true" MaxLength="255"/>
> <Property Name="CreationTime" Type="Edm.DateTime" Nullable="true"/>
> <Property Name="Currency" Type="Edm.String" Nullable="true" MaxLength="255"/>
> <Property Name="Margin" Type="Edm.Decimal" Nullable="true"/>
> <Property Name="ParentStructureElement" Type="Edm.String" Nullable="true" MaxLength="255"/>
> <Property Name="Project" Type="Edm.String" Nullable="true"/>
> <Property Name="Quantity" Type="Edm.Decimal" Nullable="true"/>
> <Property Name="Revenue" Type="Edm.Decimal" Nullable="true"/>
> <Property Name="StructureElement" Type="Edm.String" Nullable="true" MaxLength="255"/>
> <Property Name="StructureElementDescription" Type="Edm.String" Nullable="true" MaxLength="255"/>
> <Property Name="UnitOfMeasure" Type="Edm.String" Nullable="true" MaxLength="255"/>
> <Property Name="Uuid" Type="Edm.String" Nullable="false"/>
> <NavigationProperty Name="ProjectDetails" Relationship="project.Project_ProjectCost_One_Many0" FromRole="ProjectCost" ToRole="Project"/>
> </EntityType>
> <Association Name="Project_ProjectCost_One_Many0">
> <End Type="project.Project" Multiplicity="0..1" Role="Project"/>
> <End Type="project.ProjectCost" Multiplicity="*" Role="ProjectCost"/>
> <ReferentialConstraint>
> <Principal Role="Project">
> <PropertyRef Name="Uuid"/>
> </Principal>
> <Dependent Role="ProjectCost">
> <PropertyRef Name="Project"/>
> </Dependent>
> </ReferentialConstraint>
> </Association>
> <EntityContainer Name="projectContainer" m:IsDefaultEntityContainer="true">
> <EntitySet Name="Projects" EntityType="project.Project"/>
> <EntitySet Name="ProjectCosts" EntityType="project.ProjectCost"/>
> <AssociationSet Name="Project_ProjectCost_One_Many0Set" Association="project.Project_ProjectCost_One_Many0">
> <End EntitySet="Projects" Role="Project"/>
> <End EntitySet="ProjectCosts" Role="ProjectCost"/>
> </AssociationSet>
> </EntityContainer>
> </Schema>
> </edmx:DataServices>
> </edmx:Edmx>{quote}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)