Changes

API Sample Code

6,559 bytes added, 16:59, 25 November 2020
no edit summary
=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_apiapi.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>'''
'''<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----------
----------Jquery Ajax Request----------
 
 
function api_call() {
request = $.ajax(
===Response Code===
<pre>{
message: {},
records: [
==Get a Contact Record==
===Request Code===
<pre>----------HTTP POST Request----------  
Parameters (case sensitive)
url: "/API/1/user/"
----------Jquery Ajax Request----------
 
 
function api_call() {
request = $.ajax(
==Get a List of Organizations==
===Request Code===
<pre>----------HTTP POST Request----------  
Parameters (case sensitive)
url: "/API/1/company/"
===Response Code===
<pre>{
message: {},
records: [
==Get a List of Contacts==
===Request Code===
<pre>----------HTTP POST Request----------  
Parameters (case sensitive)
url: "/API/1/user/"
----------Jquery Ajax Request----------
----------Jquery Ajax Request----------
function api_call() {
request = $.ajax(
});
}
</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>
'''<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")
</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]]
Smartstaff, administrator
3,320
edits