添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
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

Hi @Arun I tried that, but getting this 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] – Suraj h k Oct 16, 2018 at 6:52 This works if I hit the URL directly from postman. I am facing problem with Olingo, I don't think we can navigate using "/" in olingo. – Suraj h k Oct 16, 2018 at 6:52 I need to say - expand OptionSet in Attributes where Attribute is of type PicklistAttributeMetadata – Suraj h k Oct 16, 2018 at 6:53 @Surajhk but you are not using the same request in postman & olingo. Ie PicklistAttributeMetadata vs AttributeMetadata – Arun Vinoth-Precog Tech - MVP Oct 16, 2018 at 11:59 In olingo I cannot say Attributes/Microsoft.Dynamics.CRM.PicklistAttributeMetadata($expand=OptionSet), what is equivalent of /Attributes/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$expand=OptionSet in olingo ? – Suraj h k Oct 16, 2018 at 13:25

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.