Trouble pulling OpportunityFileCollection associated with an Opportunity using OData service

Hello,

I'm trying to get the list of OpportunityFile associated with an Opportunity with no success.

I tried the following requests:

1.Using the link Url I'm getting a "Not Implemented" exception.

https://.bpmonline.com/0/ServiceModel/EntityDataService.svc/Opportunity…

<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<script/>
<code>4

Not Implemented

Not Implemented
System.Data.Services.DataServiceException

at System.Data.Services.WebUtil.GetRequestEnumerator(IEnumerable enumerable)
at System.Data.Services.DataService`1.SerializeResponseBody(RequestDescription description, IDataService dataService, IODataResponseMessage responseMessage)
at System.Data.Services.DataService`1.HandleRequest()

Method 'SelectMany' not supported
System.NotSupportedException

at Terrasoft.Core.Entities.EntityQueryProvider.VisitMethodCall(MethodCallExpression node)
at Terrasoft.Core.Entities.EntityQueryProvider.Build(Expression expression)
at Terrasoft.Core.Entities.EntityQueryProvider.LoadEntityCollection(Expression expression)
at Terrasoft.Core.Entities.EntityQueryProvider.ExecuteEnumerable(Type elementType, Expression expression)
at Terrasoft.Core.Entities.EntityQuery`1.GetEnumerator()
at System.Data.Services.WebUtil.GetRequestEnumerator(IEnumerable enumerable)

2. Using the $filter based on OpportunityId I'm receiving an exception saying the "OpportunityId not found".

https://.bpmonline.com/0/ServiceModel/EntityDataService.svc/Opportunity… eq guid''

<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<script/>
<code>1

Collection item with name OpportunityId not found.

Collection item with name OpportunityId not found.
Terrasoft.Common.ItemNotFoundException

at Terrasoft.Core.Entities.EntitySchema.GetSchemaColumnByPath(String columnPath)
at Terrasoft.Core.Entities.EntityQueryWhereBlockBuilder.CreateExpression(Expression node)
at Terrasoft.Core.Entities.EntityQueryWhereBlockBuilder.CreateSimpleFilter(BinaryExpression binary)
at Terrasoft.Core.Entities.EntityQueryWhereBlockBuilder.CreateFilter(Expression node)
at Terrasoft.Core.Entities.EntityQueryWhereBlockBuilder.BuildBlock(MethodCallExpression node)
at Terrasoft.Core.Entities.EntityQueryProvider.VisitMethodCall(MethodCallExpression node)
at Terrasoft.Core.Entities.EntityQueryProvider.Build(Expression expression)
at Terrasoft.Core.Entities.EntityQueryProvider.LoadEntityCollection(Expression expression)
at Terrasoft.Core.Entities.EntityQueryProvider.ExecuteEnumerable(Type elementType, Expression expression)
at Terrasoft.Core.Entities.EntityQuery`1.GetEnumerator()
at System.Data.Services.WebUtil.GetRequestEnumerator(IEnumerable enumerable)
at System.Data.Services.DataService`1.SerializeResponseBody(RequestDescription description, IDataService dataService, IODataResponseMessage responseMessage)
at System.Data.Services.DataService`1.HandleRequest()

How can I get the list and avoid the exceptions? 

Thanks in advance. 

Like 0

Like

3 comments

Hello Radu,

You can use the following filter to accomplish this: 

https://<server>.bpmonline.com/0/ServiceModel/EntityDataService.svc/OpportunityFileCollection?$filter=Opportunity/Id eq guid'<opportunity_id>'

Note, the filter itself is as follows (forward slash between the Opportunity and Id): 

Opportunity/Id eq guid'someguid'

Ryan

Ryan Farley,

Thanks Ryan. It works.

Hello Radu,



You are experiencing such difficulties cause request is built in wrong way.

Also, check Ryan`s answer above, it seems that it`s correct.



How to create request with filter to ODATA service you can find here:

https://academy.bpmonline.com/documents/technic-sdk/7-13/examples-reque…

Show all comments