Hello,
Sorry if this has been asked before, I have been searching but cannot find an answer to the problem I'm having.
I'm working on Dynamics 365 CE on premises and created a new virtual entity with a custom data provider, the new entity has the following code:
using Microsoft.Xrm.Sdk; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Runtime.Serialization.Json; using System.Text; namespace CustomDataProvider { ////// Retrieves some chosen data for all Launches from the SpaceX API /// public class RetrieveMultiplePlugin : IPlugin { public void Execute(IServiceProvider serviceProvider) { var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); var service = ((IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory))).CreateOrganizationService(new Guid?(context.UserId)); var tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService)); EntityCollection ec = new EntityCollection(); tracingService.Trace("Starting to retrieve SpaceX Launch data"); try { // Get data about SpaceX Launches var webRequest = WebRequest.Create("http://lisvpsewi/lifeServices/data.json") as HttpWebRequest; // This file has just one line of data if (webRequest == null) { return; } webRequest.ContentType = "application/json"; using (var s = webRequest.GetResponse().GetResponseStream()) { List launches = null; using (var sr = new StreamReader(s)) { var launchesAsJson = sr.ReadToEnd(); using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(launchesAsJson))) { DataContractJsonSerializerSettings settings = new DataContractJsonSerializerSettings() { UseSimpleDictionaryFormat = true }; DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(List), settings); launches = (List)ser.ReadObject(stream); } tracingService.Trace("Total number of Launches: {0}", launches.Count); ec.Entities.AddRange(launches.Select(l => l.ToEntity(tracingService))); } } } catch (Exception e) { tracingService.Trace("Exception with message: {0}", e.Message); } // Set output parameter context.OutputParameters["BusinessEntityCollection"] = ec; } } }
I loaded the assembly, created the data provider, went to administration, created the data provider there too, in my virtual entity I selected the new data provider and went to test it.
When I try to query it I get the following message:
But if I go to the plugin trace log I can see that it retrieved the data correctly and there's no error there:
Searching I found that this can be caused due to an update made, but not the cause or the way to fix it, this solution and entity are new.
Is there something I'm missing or does anyone have any idea or why does this happen.