Hello,
I need help plz
I wanted to create a web service rest that will connect to the crm
To do this I started with a console application to test the connection to my CRM organization
Here is the example that works
CrmServiceClient conn = new Microsoft.Xrm.Tooling.Connector.CrmServiceClient (@"Url=https://otest.scom.fr/otest; Domain=AB; Username=AB\admin; Password=pass; AuthType=IFD;"); IOrganizationService service = (IOrganizationService)conn.OrganizationServiceProxy; Entity _contact = new Entity("contact"); _contact.Attributes["firstname"] = "jan"; _contact.Attributes["lastname"] = "ban"; Guid contactId = service.Create(_contact);
So I used the same code to make my rest api , But it does not work
public class CRMController : ApiController { // GET: api/CRM public IEnumerable<string> Get() { return new string[] { "value1", "value2" }; } // GET: api/CRM/5 public string Get(int id) { CrmServiceClient conn = new Microsoft.Xrm.Tooling.Connector.CrmServiceClient (@"Url=https://otest.scom.fr/otest; Domain=AB; Username=AB\admin; Password=pass; AuthType=IFD;"); IOrganizationService service = (IOrganizationService)conn.OrganizationServiceProxy; Entity _contact = new Entity("contact"); _contact.Attributes["firstname"] = "jan"; _contact.Attributes["lastname"] = "ban"; Guid contactId = service.Create(_contact); return contactId.ToString(); } // POST: api/CRM public void Post([FromBody]string value) { } // PUT: api/CRM/5 public void Put(int id, [FromBody]string value) { } // DELETE: api/CRM/5 public void Delete(int id) { } }
and service = null;
*This post is locked for comments