Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
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]
Maybe you should update the third lines as below:
absoluteUri.expand("Attributes/Microsoft.Dynamics.CRM.PicklistAttributeMetadata($expand=OptionSet)");
The error message says Microsoft.Dynamics.CRM.AttributeMetadata
not PicklistAttributeMetadata
–
–
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.