
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
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)