Hello everybody,
SharePoint has been integrated in our Dynamics CRM Online (Settings > Document Management then Enable server-based SharePoint integration, etc...) and enabled for a few entities (i.e. contact or account).
I can query sharepointdocument entity with XrmToolbox
<fetch top="50"> <entity name="sharepointdocument"> <filter type="and"> <condition attribute="regardingobjecttypecode" operator="eq" value="2" /> <condition attribute="regardingobjectid" operator="eq" value="1053ec5b-b4ab-ed11-83fe-000d3a959720" uiname="Klee Paul" uitype="contact" /> </filter> </entity> </fetch>
But the same query doesn't work from a .net core 6.0 application / Microsoft.PowerPlatform.Dataverse.Client latest stable (1.0.39), either console or webapp.
string fetchquery = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'> <entity name='sharepointdocument'> <filter type='and'> <condition attribute='regardingobjecttypecode' operator='eq' value='2' /> <condition attribute='regardingobjectid' operator='eq' value='1053ec5b-b4ab-ed11-83fe-000d3a959720' uiname='Klee Paul' uitype='contact' /> </filter> </entity> </fetch>"; EntityCollection list = _svcClient.RetrieveMultiple(new FetchExpression(fetchquery)); foreach (Entity entity in list.Entities) { // do something }
or with QueryExpression
QueryExpression query = new QueryExpression("sharepointdocument"); query.ColumnSet = new ColumnSet(true); var filter = new FilterExpression(); filter.AddCondition(new ConditionExpression("regardingobjecttypecode", ConditionOperator.Equal, 2)); Guid contactId = Guid.Parse("1053ec5b-b4ab-ed11-83fe-000d3a959720"); filter.AddCondition(new ConditionExpression("regardingobjectid", ConditionOperator.Equal, contactId)); query.Criteria = filter; query.AddOrder("fullname", OrderType.Ascending); EntityCollection list = _svcClient.RetrieveMultiple(query); foreach (Entity entity in list.Entities) { // Do something }
The error is
Unhandled exception: System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault] : At least 1 Claim must not be NULL, current claims are : nameid=;nii=urn:federation:microsoftonline (le détail de l'erreur est égal à Exception details:
ErrorCode: 0x80040216
Message: At least 1 Claim must not be NULL, current claims are : nameid=;nii=urn:federation:microsoftonline
Then I tried to set _svcClient.CallerId with admin user (which was not necessary in other queries in my app) but same error.
Am I missing something ? Is there a way to query sharepointdocument from C# ?
Thanks in advance !