Skip to content

Instantly share code, notes, and snippets.

@ilgrosso
Last active January 4, 2016 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilgrosso/8674028 to your computer and use it in GitHub Desktop.
Save ilgrosso/8674028 to your computer and use it in GitHub Desktop.
ODataJClient4: EntityRetrieve
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...
@ilgrosso
Copy link
Author

More information on ODataEntity in the Javadocs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment