Last active
January 4, 2016 20:29
-
-
Save ilgrosso/8674028 to your computer and use it in GitHub Desktop.
ODataJClient4: EntityRetrieve
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ODataClient client = ODataClientFactory.getV3(); // or ODataClientFactory.getV4(); | |
String serviceRoot = ...; | |
URIBuilder uriBuilder = client.getURIBuilder(serviceRoot). | |
appendEntityTypeSegment("Customer").appendKeySegment(-10).expand("Info"); | |
// long version (using ATOM) | |
ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); | |
req.setFormat(ODataPubFormat.ATOM); | |
ODataRetrieveResponse<ODataEntity> res = req.execute(); | |
ODataEntity entity = res.getBody(); | |
// short version (using JSON light, default) | |
ODataEntity entity = client.getRetrieveRequestFactory(). | |
getEntityRequest(uriBuilder.build()).execute().getBody(); | |
// now access ODataEntity's properties, link, operations... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More information on ODataEntity in the Javadocs