I am using Apache olingo v4 to fetch Microsoft Dynamics Data. I am trying to fetch an entity metadata with attributes expanded along with option set (if the attribute is of type 'Picklist').
Here is the sample code I tried:
URIBuilder absoluteUri = client.newURIBuilder("<URL>").appendEntitySetSegment("EntityDefinitions");
absoluteUri.filter("LogicalName eq 'account'");
absoluteUri.expand("Attributes($expand=OptionSet)");
URI uri = absoluteUri.build();
ODataRawRequest request = client.getRetrieveRequestFactory().getRawRequest(absoluteUri);
request.setAccept("application/json;odata.metadata=full");
ODataRawResponse response = request.execute();
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> result = mapper.readValue(response.getRawResponse(), new TypeReference<Map<String, Object>>(){});
return mapper.convertValue(result.get("value"), new TypeReference<List<Map<String,Object>>>(){});
When I run this, I get the below error:
org.apache.olingo.client.api.communication.ODataClientErrorException: (0x0) Could not find a property named 'OptionSet' on type 'Microsoft.Dynamics.CRM.AttributeMetadata'."Could not find a property named 'OptionSet' on type 'Microsoft.Dynamics.CRM.AttributeMetadata'." [HTTP/1.1 400 Bad Request]
How do I do this with Olingo? If I have to do this via postman, I can just hit this url
GET [Organization URI]/api/data/v9.0/EntityDefinitions(LogicalName='account')/Attributes/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$expand=OptionSet
Update: I edited the 3rd line to below:
absoluteUri.expand("Attributes/Microsoft.Dynamics.CRM.PicklistAttributeMetadata($expand=OptionSet)");
Got the below error:
org.apache.olingo.client.api.communication.ODataClientErrorException: (0x0) Found a path traversing multiple navigation properties. Please rephrase the query such that each expand path contains only type segments and navigation properties."Found a path traversing multiple navigation properties. Please rephrase the query such that each expand path contains only type segments and navigation properties." [HTTP/1.1 400 Bad Request]