public RestResponse<CRMFetchXML> GetEntities(CRMFetchXML crmFetch, K2CRMConfig config) { var client = new RestClient(config.RESTUrl); var request = new RestRequest(); request.Method = Method.POST; request.Credentials = config.CredentialCache; request.RequestFormat = RestSharp.DataFormat.Json; request.Resource = "K2CRM/CRMGetEntities"; request.AddBody(crmFetch); RestResponse<CRMFetchXML> response = client.Execute<CRMFetchXML>(request); return response; }
public RestResponse <CRMFetchXML> GetEntities(CRMFetchXML crmFetch, K2CRMConfig config) { var client = new RestClient(config.RESTUrl); var request = new RestRequest(); request.Method = Method.POST; request.Credentials = config.CredentialCache; request.RequestFormat = RestSharp.DataFormat.Json; request.Resource = "K2CRM/CRMGetEntities"; request.AddBody(crmFetch); RestResponse <CRMFetchXML> response = client.Execute <CRMFetchXML>(request); return(response); }
private void GetEntities(ref ServiceObject so) { SourceCode.SmartObjects.Services.ServiceSDK.Objects.Method meth = so.Methods[0]; WizardFunctions helper = new WizardFunctions(); CRMFetchXML fetch = new CRMFetchXML(); fetch.Config = crmconfig; try { fetch.FetchXML = NotNull(so.Properties["FetchXML"].Value); RestResponse <CRMFetchXML> response = helper.GetEntities(fetch, config); so.Properties.InitResultTable(); if (response.Data != null && response.Data.Entities != null) { foreach (CRMState state in response.Data.Entities) { for (int c = 0; c < meth.ReturnProperties.Count; c += 1) { Property prop = so.Properties[meth.ReturnProperties[c]]; prop = SetGetEntitiesProperties(prop, state); prop = SetGetEntitiesRESTProperties(prop, response); } so.Properties.BindPropertiesToResultTable(); } } else { for (int c = 0; c < meth.ReturnProperties.Count; c += 1) { Property prop = so.Properties[meth.ReturnProperties[c]]; prop = SetGetEntitiesRESTProperties(prop, response); } so.Properties.BindPropertiesToResultTable(); } } catch (Exception ex) { throw; } }