web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How To Do A Get Request In WCF To Get Accounts Entity Data

(0) ShareShare
ReportReport
Posted on by

Hello Guys,

I want to do a get request using rest to get accounts entity data of MS CRM  in WCF interface Is this possible?? i am using .net framework 4.5.2 and iis express to debug in visual studio 2012 i am getting the following error when i try to do a getaccount() request is this a iis express error or .net framework in visual studio please help

8156.err.png5736.err1.png

MyCode

public class Accounts : IAccounts
{
private OrganizationServiceProxy _serviceProxy;
private IOrganizationService _service;

public List<Account> getAccountDetails()
{
var connection = new CrmConnection("Crm");
var service = new OrganizationService(connection);
var context = new CrmOrganizationServiceContext(connection);

string fetchXml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='account'>
<attribute name='name' />
<attribute name='address1_city' />
<attribute name='primarycontactid' />
<attribute name='telephone1' />
<attribute name='accountid' />
<order attribute='name' descending='false' />
<filter type='and'>
<condition attribute='ownerid' operator='eq-userid' />
<condition attribute='statecode' operator='eq' value='0' />
</filter>
<link-entity name='contact' from='contactid' to='primarycontactid' visible='false' link-type='outer' alias='accountprimarycontactidcontactcontactid'>
<attribute name='emailaddress1' />
</link-entity>
</entity>
</fetch>";

EntityCollection result = _service.RetrieveMultiple(new FetchExpression(fetchXml));

List<Account> accountlist = new List<Account>();
foreach (var item in result.Entities)
{
Account acc = new Account();
acc.fullname = item.Attributes["fullname"].ToString();
acc.companyname = item.Attributes["companyname"].ToString();
acc.telephone = item.Attributes["telephone1"].ToString();
}
return accountlist;

}

///////////////////////////

[ServiceContract]
public interface IAccounts
{
[OperationContract]
[WebInvoke(Method = "GET",
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "Accounts",
ResponseFormat = WebMessageFormat.Json)]
List<Account> getAccountDetails();

}

 

 

*This post is locked for comments

I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans