Changes

API Sample Code

9,579 bytes added, 19:12, 23 March 2016
no edit summary
__TOC__
=Sample Code from JSON API (SmartConnect)=The following are excerpts from SmartConnect, SmartSimple's RESTful JSON API. To review how the JSON API works in greater detail, and interact with some sample functions and test data, be sure to visit the [https://api.smartsimple.com/devtools/dev_api.html Interactive Demonstration Page]. This webpage is connected to a specific demonstration instance that contains sample data for API testing. '''<big><big>[https://api.smartsimple.com/devtools/dev_api.html Interactive Demonstration Page]</big></big>'''  ==Get a Company Record=====Request Code===<pre>----------HTTP POST Request----------  Parameters (case sensitive)url: "/API/1/company/"*companyid : 825646*alias : api*username : smartconnectdemo@smartsimple.com*password : *****************  apitoken : CllAZXoBSn9PUHNVejJxfUA2D3dEcmNnAjI~  --Begin custom parameter (replace '{parameter}' with actual value)--recordid : 825646 --End custom parameter--  *Only required if calls are originated from remote server ----------Jquery Ajax Request----------function api_call() { request = $.ajax(  { url: "/API/1/company/",  {type: "POST", data: {apitoken: "CllAZXoBSn9PUHNVejJxfUA2D3dEcmNnAjI~",recordid : 825646 }, dataType: "html" }); request.done(function( data ) { //TODO }); }</pre> ===Response Code===<pre>{ message: {}, records: [ { sf_Name: "SmartSimple Software Inc", cf_Mission Statement: "SmartSimple was designed from the start to help organizations connect with their communities and streamline<br /> critical processes. We're able to do this because our products are almost endlessly configurable. Once a system is implemented, <br /> our clients are able to administer their software on their own, with minimal help from us.", sf_Company ID: "825646", sf_Address: "111 Peter Street", sf_Country: "Canada", cf_EIN Number: null, sf_Zip / Postal Code: "M5V 2H1", sf_City: "Toronto" } ]} </pre>  ==Get a Contact Record=====Request Code===<pre>----------HTTP POST Request----------Parameters (case sensitive)url: "/API/1/user/"*companyid : 825646*alias : api*username : smartconnectdemo@smartsimple.com*password : *****************  apitoken : fzJnYl1lakhFcVJnWwF5Y2xEelNDdXVOAgY~  --Begin custom parameter (replace '{parameter}' with actual value)--recordid : 825646 --End custom parameter--  *Only required if calls are orginated from remote server  ----------Jquery Ajax Request---------- function api_call() { request = $.ajax(  { url: "/API/1/user/",  {type: "POST", data: {apitoken: "fzJnYl1lakhFcVJnWwF5Y2xEelNDdXVOAgY~",recordid : 825646 }, dataType: "html" }); request.done(function( data ) { //TODO }); }</pre>  ==Get a List of Organizations=====Request Code===<pre>----------HTTP POST Request----------Parameters (case sensitive)url: "/API/1/company/"*companyid : 825646*alias : api*username : smartconnectdemo@smartsimple.com*password : *****************  apitoken : SnZnAgVGVwpSUERfDVUMVXpGYWViXQFTAgc~  --Begin custom parameter (replace '{parameter}' with actual value)--criteria : {parameter} //Optional: json array each condition contains nodes "andor", "field", "operator", "value" eg[{"andor":"and","field":"FIELDNAME","operator":"like","value":"PATTERN"},{"andor":"or","field":"FIELDNAME","operator":"like","value":"PATTERN"}]sortby : {parameter} //Optional: json array each sort by field contains nodes "field", "direction" eg. [{"field":"FIELDNAME","direction":"asc|desc"}]getstorevalue : {parameter} //Optional: int type: 0 = no (get display value), 1 = yes (get stored value)--End custom parameter--  *Only required if calls are orginated from remote server    ----------Jquery Ajax Request----------   function api_call() { request = $.ajax(  { url: "/API/1/company/",  {type: "POST", data: {apitoken: "SnZnAgVGVwpSUERfDVUMVXpGYWViXQFTAgc~" }, dataType: "html" }); request.done(function( data ) { //TODO }); }</pre>  ===Response Code===<pre>{ message: {}, records: [ { sf_Name: "SmartSimple Software Inc", cf_Mission Statement: "SmartSimple was designed from the start to help organizations connect with their communities and streamline<br /> critical processes. We're able to do this because our products are almost endlessly configurable. Once a system is implemented, our<br /> clients are able to administer their software on their own, with minimal help from us.", sf_Company ID: "825646", sf_Address 2: "Suite 405", sf_Address: "111 Peter Street", sf_Country: "Canada", sf_Zip / Postal Code: "M5V 2H1", sf_State / Province: "Ontario", sf_City: "Toronto" }, { sf_Name: "Grant Seeking Organizations", cf_Mission Statement: "", sf_Company ID: "825805", sf_Address 2: "", sf_Address: "4555 Westchester Street", sf_Country: "United States", sf_Zip / Postal Code: "", sf_State / Province: "NY", sf_City: "New York City" }, { sf_Name: "Prospect Heights Educational Campus", cf_Mission Statement: "", sf_Company ID: "825806", sf_Address 2: "", sf_Address: "5108 4th Ave. At 51st St.", sf_Country: "--- Select One ---", sf_Zip / Postal Code: "", sf_State / Province: "New York", sf_City: "Brooklyn" }, { sf_Name: "Acme Insurance", cf_Mission Statement: "", sf_Company ID: "826093", sf_Address 2: "", sf_Address: "111 Peter Street, Suite 405", sf_Country: "--- Select One ---", sf_Zip / Postal Code: "", sf_State / Province: "", sf_City: "" } ], header: [ { id: "sf_Name", index: "1", name: "Name", caption: "Organization Name" }, { id: "sf_Address", index: "2", name: "Address", caption: "Address" }, { id: "sf_Address 2", index: "3", name: "Address 2", caption: "Address 2" }, { id: "sf_City", index: "4", name: "City", caption: "City" }, { id: "sf_State / Province", index: "5", name: "State / Province", caption: "State" }, { id: "sf_Country", index: "6", name: "Country", caption: "Country" }, { id: "sf_Zip / Postal Code", index: "7", name: "Zip / Postal Code", caption: "Zip / Postal Code" }, { id: "sf_Company ID", index: "8", name: "Company ID", caption: "" }, { id: "cf_1523156", index: "9", name: "Mission Statement", caption: "Mission Statement" } ] }}</pre>  ==Get a List of Contacts=====Request Code===<pre>----------HTTP POST Request----------Parameters (case sensitive)url: "/API/1/user/"*companyid : 825646*alias : api*username : smartconnectdemo@smartsimple.com*password : *****************  apitoken : TmZ3NmRFdUIBZ1tFFwYeAlB!e3FlV3FjAgMG  --Begin custom parameter (replace '{parameter}' with actual value)--criteria : {parameter} //Optional: json array each condition contains nodes "andor", "field", "operator", "value" eg[{"andor":"and","field":"FIELDNAME","operator":"like","value":"PATTERN"},{"andor":"or","field":"FIELDNAME","operator":"like","value":"PATTERN"}]sortby : {parameter} //Optional: json array each sort by field contains nodes "field", "direction" eg. [{"field":"FIELDNAME","direction":"asc|desc"}]getstorevalue : {parameter} //Optional: int type: 0 = no (get display value), 1 = yes (get stored value)--End custom parameter--  *Only required if calls are orginated from remote server    ----------Jquery Ajax Request---------- function api_call() { request = $.ajax(  { url: "/API/1/user/",  {type: "POST", data: {apitoken: "TmZ3NmRFdUIBZ1tFFwYeAlB!e3FlV3FjAgMG" }, dataType: "html" }); request.done(function( data ) { //TODO }); }</pre>  ==Additional SmartConnect API Sample Code==We have built a resource that allows you to build and run some of the most common API functions. This resource is connected to a specific demonstration instance that contains sample data for API testing. '''<big><big>[https://api.smartsimple.com/devtools/dev_api.html Interactive Demonstration Page]</big></big>'''  =Deprecated Sample Code from Desktop API=The following are excerpts of SmartSimple 's Deprecated Desktop API code written in Microsoft Visual Basic:
<pre>
2,004
edits