c# - Restsharp will not populate my class with a Zoho CRM request -
i have tried several variations of code. while debugging see pulls xml file, can not populate class created. have read posts on here , few examples around web. have tried proxy class , others. each time response can not populate class. having problems trying use enumeration of class. errors before compiling had go route below.
i using c# .net 4.5 , visual studio 2012 along latest restsharp.
note: beginner c# able tell. self learning project. 1 of clients (i services small biz) gave me access zoho play api.
question: need suggestion or pointing in right direction.
thank in advanced
my model:
using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; namespace zoho.mapping.rest { public class potentials { public string potentialid { get; set; } public string smownerid { get; set; } public string potential_owner { get; set; } public string amount { get; set; } public string potential_name { get; set; } public string closing_date { get; set; } public string stage { get; set; } public string next_step { get; set; } public string lead_source { get; set; } public string smcreatorid { get; set; } public string created_by { get; set; } public string modifiedby { get; set; } public string modified_by { get; set; } public string created_time { get; set; } public string modified_time { get; set; } public string description { get; set; } public string contactid { get; set; } public string contact_name { get; set; } public string last_activity_time { get; set; } public string lead_conversion_time { get; set; } public string sales_cycle_duration { get; set; } public string overall_sales_duration { get; set; } public string best_daytime_contact { get; set; } public string priority { get; set; } public string services { get; set; } public string type_of_home { get; set; } public string home_phone { get; set; } public string source_description { get; set; } public string property_name { get; set; } public string current_mowing_service { get; set; } public string current_lawn_care_service { get; set; } public string current_mowing_price { get; set; } public string current_lawn_care_price { get; set; } } }
my main method
using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using zoho.mapping.app_code; using zoho.mapping; using zoho.mapping.rest; using restsharp; namespace testzoho { class program { static void main(string[] args) { var usertoken = "mylongtokennumberhere"; restclient client = new restclient(); client.baseurl = "https://crm.zoho.com/crm/private/xml/"; restrequest request = new restrequest(method.get); request.resource = "{module}/{method}"; request.addparameter("module", "potentials", parametertype.urlsegment); request.addparameter("method", "getrecords", parametertype.urlsegment); request.addparameter("authtoken", usertoken); request.addparameter("scope", "crmapi"); request.addparameter("newformat", "1"); request.addparameter("selectcolumns", "all"); request.rootelement = "potentials"; //var response = client.execute<potentials>(request); irestresponse responselistpotentials = client.execute(request); var xmlcontent = responselistpotentials.content; console.writeline(xmlcontent); console.readline(); } } }
the zohocrm api output:
<?xml version="1.0" encoding="utf-8"?> <response uri="/crm/private/xml/potentials/getrecords"> <result> <potentials> <row no="1"> <fl val="potentialid">683271000001660139</fl> <fl val="smownerid">683271000000415037</fl> <fl val="potential owner"><![cdata[barbara figueroa]]></fl> <fl val="amount"><![cdata[0]]></fl> <fl val="potential name"><![cdata[sist, lee , linda]]></fl> <fl val="closing date"><![cdata[2013-04-30]]></fl> <fl val="stage"><![cdata[qualified meeting set]]></fl> <fl val="next step"><![cdata[null]]></fl> <fl val="lead source"><![cdata[church bulletin]]></fl> <fl val="smcreatorid">683271000000415037</fl> <fl val="created by"><![cdata[barbara figueroa]]></fl> <fl val="modifiedby">683271000000415025</fl> <fl val="modified by"><![cdata[barbara suthard]]></fl> <fl val="created time"><![cdata[2013-04-16 17:18:24]]></fl><fl val="modified time"><![cdata[2013-04-16 17:37:19]]></fl> <fl val="description"><![cdata[lc, lcl, - wants face face has lot of lawn work clean trimming etc.]]></fl><fl val="contactid">683271000001660133</fl> <fl val="contact name"><![cdata[lee , linda sist]]></fl> <fl val="last activity time"><![cdata[2013-04-16 17:37:19]]></fl> <fl val="lead conversion time"><![cdata[null]]></fl> <fl val="sales cycle duration"><![cdata[14]]></fl> <fl val="overall sales duration"><![cdata[14]]></fl> <fl val="best daytime contact"><![cdata[phone (work)]]></fl> <fl val="services"><![cdata[null]]></fl> <fl val="priority"><![cdata[null]]></fl> <fl val="type of home"><![cdata[single family home]]></fl> <fl val="home phone"><![cdata[null]]></fl> <fl val="source description"><![cdata[null]]></fl> <fl val="property name"><![cdata[9757 copeland drive, manassas, va 20109]]></fl> <fl val="current mowing service"><![cdata[none]]></fl> <fl val="current lawn care service"><![cdata[none]]></fl> <fl val="current mowing price"><![cdata[0]]></fl> <fl val="current lawn care price"><![cdata[0]]></fl> </row> <row no="2"> <fl val="potentialid">683271000001660123</fl> <fl val="smownerid">683271000000415031</fl> <fl val="potential owner"><![cdata[robb boutelle]]></fl> <fl val="amount"><![cdata[0]]></fl> <fl val="potential name"><![cdata[lapetina, christine]]></fl> <fl val="closing date"><![cdata[2013-04-30]]></fl> <fl val="stage"><![cdata[unqualified]]></fl> <fl val="next step"><![cdata[null]]></fl> <fl val="lead source"><![cdata[existing customer]]></fl> <fl val="smcreatorid">683271000000415037</fl> <fl val="created by"><![cdata[barbara figueroa]]></fl> <fl val="modifiedby">683271000000415037</fl> <fl val="modified by"><![cdata[barbara figueroa]]></fl> <fl val="created time"><![cdata[2013-04-16 15:30:23]]></fl> <fl val="modified time"><![cdata[2013-04-16 15:30:23]]></fl> <fl val="description"><![cdata[lhs - not need appt call before going out can unlock gate. has flagstone walkway needs extended , redone]]></fl> <fl val="contactid">683271000000887054</fl> <fl val="contact name"><![cdata[christine lapetina]]></fl> <fl val="last activity time"><![cdata[2013-04-16 15:30:23]]></fl> <fl val="lead conversion time"><![cdata[null]]></fl> <fl val="sales cycle duration"><![cdata[14]]></fl> <fl val="overall sales duration"><![cdata[14]]></fl> <fl val="best daytime contact"><![cdata[home]]></fl> <fl val="services"><![cdata[leaves]]></fl> <fl val="priority"><![cdata[2]]></fl> <fl val="type of home"><![cdata[single family home]]></fl> <fl val="home phone"><![cdata[null]]></fl> <fl val="source description"><![cdata[null]]></fl> <fl val="property name"><![cdata[4812 twinbrook rd, fairfax, va 22032-2049]]></fl> <fl val="current mowing service"><![cdata[none]]></fl> <fl val="current lawn care service"><![cdata[none]]></fl> <fl val="current mowing price"><![cdata[0]]></fl> <fl val="current lawn care price"><![cdata[0]]></fl> </row> </potentials> </result> </response>
Comments
Post a Comment