如何在Apache Olingo中发布/放置实体/实体集的LIST?

时间:2017-01-25 13:49:39

标签: java rest odata olingo

我想HTTP-PUT实体/ entitySet列表(我猜它与HTTP-POST类似)。下面是查询的正文。此查询适用于Postman。

 {
  "value": [
    {
        "@odata.type": "Demo.GridPoint",
        "x": 2.2,
        "y": 1.2
    },
    {
        "@odata.type": "Demo.GridPoint",
        "x": 4,
        "y": 5
    },
    {
        "@odata.type": "Demo.GridPoint",
        "x": 1,
        "y": 9
    }
  ]
}

Demo.GridPointComplexType

我尝试创建ClientEntity并将不同的值添加为ComplexProperty

ClientEntity coordinates = client.getObjectFactory().newEntity(coordinatesFqn);
for(/* all grid Points */){
    coordinates.add(client.getObjectFactory().newComplexProperty("", gridPoint));
}

但是,功能newComplexProperty(String name, ClientComplexValue value)需要ComplexValue 一个名称。因此,生成的查询不符合预期的格式并失败:

{"@odata.type":"Demo.Coordinates",
"":{"@odata.type":"Demo.GridPoint","x@odata.type":"Double","x":2.2,"y@odata.type":"Double","y":1.2},
"":{"@odata.type":"Demo.GridPoint","x@odata.type":"Double","x":4,"y@odata.type":"Double","y":5}
"":{"@odata.type":"Demo.GridPoint","x@odata.type":"Double","x":1,"y@odata.type":"Double","y":9}
}

如何POST / PUT实体列表/ EntitySet?

1 个答案:

答案 0 :(得分:0)

您可以添加对批量请求的支持。它们允许您在一个请求中发送多个请求。

http://www.odata.org/documentation/odata-version-2-0/batch-processing/