The following are excerpts of API code written in Microsoft Visual Basic:__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/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/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> ==Get a Meta Data from a UTA=====Request Code===<pre>----------HTTP POST Request---------- Parameters (case sensitive)url: "/API/1/levelone/"*companyid : 825646*alias : api*username : smartconnectdemo@smartsimple.com*password : ***************** apitoken : U2N4RwUBTn5XZldZXFdfWX1@C2JAWXVuAjIF --Begin custom parameter (replace '{parameter}' with actual value)----End custom parameter-- *Only required if calls are orginated from remote server ----------Jquery Ajax Request---------- function api_call() { request = $.ajax( { url: "/API/1/levelone/", {type: "POST", data: {apitoken: "U2N4RwUBTn5XZldZXFdfWX1@C2JAWXVuAjIF" }, dataType: "html" }); request.done(function( data ) { //TODO }); }</pre>===Response Code===<pre>{ hassubactivity: false, message: {}, levelonename: "Cases", levelthreename: "Level 3 Activities", leveltwoname: "Services", menuname: "Case Manager", leveltwo: { statuses: [ { description: "", name: "To be scheduled" }, { description: "", name: "Scheduled" }, { description: "", name: "Application Letter Sent to Insured" }, { description: "", name: "Assessment Plan Received" }, { description: "", name: "Late Cancellation" }, { description: "", name: "Examination Notice Sent to Vendor" }, { description: "", name: "Report Received" }, { description: "", name: "On Hold" }, { description: "", name: "Report Due Today" }, { description: "", name: "No Show" }, { description: "", name: "Completed" }, { description: "", name: "Submitted" }, { description: "", name: "Completed - Billed" }, { description: "", name: "Non-Billable" } ], types: [ { name: "--- Select One ---", caption: "", fields: [] }, { name: "Addendum", caption: "", fields: [] }, { name: "Addendum - In Response to a Sect. 42.1", caption: "", fields: [] }, { name: "Adjuster Approved Service", caption: "", fields: [] }, { name: "Cardiology Assessment", caption: "", fields: [] }, { name: "Chiropractic Assessment", caption: "", fields: [] }, { name: "Dental Assessment", caption: "", fields: [] }, { name: "Diagnostic Test", caption: "", fields: [] }, { name: "Education Session", caption: "", fields: [] }, { name: "Employer Contact", caption: "", fields: [] }, { name: "Ergonomic Assessment", caption: "", fields: [] }, { name: "Exercise Program", caption: "", fields: [] }, { name: "FAE - Functional Abilities Evaluation", caption: "", fields: [] }, ... CODE TRUNCATED ... } ] }, levelthree: {}, hasactivity: true}</pre> ==Retrieving notes from an object==Replace the URL accordingly depending on the type of object. The Objectid parameter is the ID of the record you wish to retrieve notes from. /API/1/levelone/ /API/1/leveltwo/ /API/1/levelthree/ /API/1/user/ /API/1/company/ ===Request Code===This example below retrieves notes from a Level One object with an objectid of "1136627". The criteria filter restricts the note type returned where sf_Type equals to "Staff Note". <pre>----------HTTP POST Request---------- Parameters (case sensitive)url: "/API/1/levelone/"*companyid : 825646*alias : api*username : smartconnectdemo@smartsimple.com*password : ***************** apitoken : cmFgDAIDbHFaWB9jfmsCXQRAXw5mYGlXDggF@C2JAWXVuAjIF --Begin custom parameter (replace '{parameter}' with actual value)----End custom parameter-- *Only required if calls are orginated from remote server ----------Jquery Ajax Request---------- function api_call() { request = $.ajax( { url: "/API/1/levelone/", {type: "POST", data: {apitoken: "cmFgDAIDbHFaWB9jfmsCXQRAXw5mYGlXDggF",objectid: "1136627",criteria: JSON.stringify([{"andor":"and","field":"sf_Type","operator":"like","value":"Staff Note"}]), }, dataType: "html" }); request.done(function( data ) { //TODO }); }}</pre>===Response Code===<pre>"{"message":{ },"records":[ { "sf_Type":"Internal Notes", "sf_Content":"option1", "sf_Type ID":"45377", "sf_Note ID":"2246482", "sf_Object ID":"1136627", "sf_Created By":"SmartSimple", "sf_Created Date":"2016-08-29 15:58:08", "recordid":"2246482" }, { "sf_Type":"Internal Notes", "sf_Content":"option2", "sf_Type ID":"45377", "sf_Note ID":"2246483", "sf_Object ID":"1136627", "sf_Created By":"SmartSimple", "sf_Created Date":"2016-08-29 15:58:12", "recordid":"2246483" }, { "sf_Type":"L1 Only UTA - 2 and All", "sf_Content":"option3", "sf_Type ID":"54302", "sf_Note ID":"2246484", "sf_Object ID":"1136627", "sf_Created By":"SmartSimple", "sf_Created Date":"2016-08-29 15:58:17", "recordid":"2246484" }],"header":[ ]}"</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={{Deprecated}} The following are excerpts of SmartSimple's Deprecated Desktop API code written in Microsoft Visual Basic: <pre>Dim ss_param As New SmartComClient.Parameters Call ss_param.addField("opportunityid", "0")Call ss_param.addField("companyid", "404091") Call ss_param.addField("branchid", "404091") ' Call ss_param.addField("opportunitytype", "11642") Call ss_param.addField("name", "test01err")Call ss_param.addField("stageid", "9955") Call ss_param.addField("cf_1333618", "name1")Call ss_param.addField("cf_1333619", "name2")Call ss_param.addField("cf_1590372", "Txt_ACMAddress1.Text")Call ss_param.addField("cf_1590373", "Txt_ACMAddress2.Text")Call ss_param.addField("cf_1590374", "Txt_ACMProvince.Text")Call ss_param.addField("cf_1590375", "Txt_ACMPostalCode.Text")Call ss_param.addField("cf_1590376", "DDL_CITitle.SelectedValue")Dim rtn As Longrtn = tk.updateTable(sess, "levelone", 123123, ss_param) '123123 is the applicationid If rtn = -1 Then MsgBox ("Record Not Updated: " & ss_api.getLastErr) Else </pre> <pre>Option Explicit
Dim SmartSimple As New SmartComClient.Toolkit
==See Also==
* [[API Code: Upload File to Custom FieldInteractive Demonstration Page]]
[[Category:Integration]][[Category:API]][[Category:SmartConnect RESTful API]]