Hi,
I will try to retrieve data from CRM using Fetch XML with C# but not working.please check below code and mention what wrong?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Tooling.Connector;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Query;
using System.Net;
using System.ServiceModel.Description;
namespace Retrieve_Data_using_FetchXml
{
class Program
{
static void Main(string[] args)
{
IOrganizationService organizationService = null;
ClientCredentials clientCredentials = new ClientCredentials();
clientCredentials.UserName.UserName = "admin@deveshitsol.onmicrosoft.com";
clientCredentials.UserName.Password = "bsk@2018";
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
organizationService = (IOrganizationService)new OrganizationServiceProxy(new Uri("deveshitsol.api.crm8.dynamics.com/.../Organization.svc"),
null, clientCredentials, null);
Console.WriteLine("Connection Established");
string fetch2 = @" <?xml version='1.0'?>
<fetch output - format = 'xml-platform' distinct = 'false' version = '1.0' mapping = 'logical'>
<entity name = 'icici_transaction'>
<attribute name = 'icici_name'/>
<attribute name = 'icici_transaction_name'/>
<attribute name = 'icici_customername'/>
<attribute name = 'icici_customeraccount'/>
<order attribute = 'icici_name' descending = 'false'/>
</entity>
</fetch>";
EntityCollection result = organizationService.RetrieveMultiple(new FetchExpression(fetch2));
foreach (var c in result.Entities)
{
Console.WriteLine(c.Attributes["icici_name"]);
Console.WriteLine(c.Attributes["icici_customername"]);
Console.WriteLine(c.Attributes["icici_customeraccount"]);
Console.WriteLine(c.Attributes["icici_transaction_name"]);
}
}
}
}
*This post is locked for comments
I have the same question (0)