REST API

SplendidCRM REST API

Introduction

SplendidCRM has had a SOAP API for many years.  The original SOAP API was patterned after a similar SugarCRM API so that the SplendidCRM Plug-in for Outlook could work with both SplendidCRM and SugarCRM web applications.

We created the Full-Access API to support our original SplendidCRM Offline Client.  The Full-Access API is a SOAP API that made it easy to synchronize the client to the server.

The REST API was created to support our HTML5 Offline Client and to support the various SplendidCRM browser extensions.

API Design

The SplendidCRM REST API is a layer on top of the modules. 

The REST API consists of twenty methods.  Three methods are informational, nine are for authentication and the remaining eight are for getting and updating data.  Only eight methods are used to manage data because SplendidCRM is data driven.

The REST API relies upon the existing session management of the SplendidCRM web application.  It is for this reason that it is critical that you verify that the session is authenticated before performing the module data operations.

Developer’s Note

SplendidCRM uses System.ServiceModel.Activation.WebScriptServiceHostFactory to provide REST services.  The use of WebScriptServiceHostFactory has dramatically reduced the complexity of creating a REST service, but it has its drawbacks.  The big problem, which you may encounter, is that this library cannot handle more than one binding.  Also, in Web.config, you need to make sure that aspNetCompatibilityEnabled is true.

<system.serviceModel>

     <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

</system.serviceModel>

If you get the following error, you need to remove the bindings in IIS. 

This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection.

Parameter name: item

Real-world examples of how to use the REST API can be found in the source code for the HTML5 Offline Client.  The HTLM5 Offline Client is included in all editions of SplendidCRM.


API Reference

Version

Returns the version of the SplendidCRM web application.

C# Syntax

public string Version

(

)

REST Syntax

POST http://demo.splendidcrm.com/Rest.svc/Version

Parameters

None.

Return Value

Type: System.String

{"d":"6.1.4439.35048"}

Remarks

The version, along with the edition, can be used to determine the features that are available.  The string that is returned will match the SplendidCRM version number as displayed on the About page of the web application.  The return value will look like 6.1.4439.35048.


Edition

Returns the edition of the SplendidCRM web application.

C# Syntax

public string Edition

(

)

REST Syntax

POST http://demo.splendidcrm.com/Rest.svc/Edition

Parameters

None.

Return Value

Type: System.String

{"d":"Community"}

Remarks

The version, along with the edition, can be used to determine the features that are available.  The string that is returned will match the SplendidCRM edition as displayed on the About page of the web application.  The return value will be one of the following: Enterprise, Professional or Community.


UtcTime

Returns the server time adjusted to UTC.

C# Syntax

public DateTime UtcTime

(

)

REST Syntax

POST http://demo.splendidcrm.com/Rest.svc/UtcTime

Parameters

None.

Return Value

Type: System.DateTime

{"d":"\/Date(1331613952737)\/"}

Remarks

The date value can be converted to a JavaScript date by passing the integer value to the date object.


IsAuthenticated

Returns the current authentication state.

C# Syntax

public bool IsAuthenticated

(

)

REST Syntax

POST http://demo.splendidcrm.com/Rest.svc/IsAuthenticated

Parameters

None.

Return Value

Type: System.Boolean

{"d":true}

Remarks

This method is typically called before any other operation that requires a valid and authenticated session.  The Offline Client will use this information to determine if the user needs to be authenticated prior to performing a sync operation.


GetUserID

Returns the User ID for the current user.

C# Syntax

public Guid GetUserID

(

)

REST Syntax

POST http://demo.splendidcrm.com/Rest.svc/GetUserID

Parameters

None.

Return Value

Type: System.Guid

{"d":"00000000-0000-0000-0003-000000000000"}

Remarks

.


GetUserName

Returns the User Name for the current user.

C# Syntax

public string GetUserName

(

)

REST Syntax

POST http://demo.splendidcrm.com/Rest.svc/GetUserName

Parameters

None.

Return Value

Type: System.String

{"d":"will"}

Remarks

.


GetTeamID

Returns the Team ID for the current user.

C# Syntax

public Guid GetTeamID

(

)

REST Syntax

POST http://demo.splendidcrm.com/Rest.svc/GetTeamID

Parameters

None.

Return Value

Type: System.Guid

{"d":" 17bb7135-2b95-42dc-85de-842caff927a0"}

Remarks

.


GetTeamName

Returns the Team Name for the current user.

C# Syntax

public string GetTeamName

(

)

REST Syntax

POST http://demo.splendidcrm.com/Rest.svc/GetTeamName

Parameters

None.

Return Value

Type: System.String

{"d":"Global"}

Remarks

.


GetUserLanguage

Returns the Language for the current user.

C# Syntax

public string GetUserLanguage

(

)

REST Syntax

POST http://demo.splendidcrm.com/Rest.svc/GetUserLanguage

Parameters

None.

Return Value

Type: System.String

{"d":"en-US"}

Remarks

The language is important because it is used to get the correct terminology data.  The data includes lists.


GetUserProfile

Returns the profile for the current user.

C# Syntax

public class UserProfile

{

      public Guid   USER_ID         ;

      public string USER_NAME       ;

      public Guid   TEAM_ID         ;

      public string TEAM_NAME       ;

      public string USER_LANG       ;

      public string USER_DATE_FORMAT;

      public string USER_TIME_FORMAT;

}

 

public UserProfile GetUserProfile

(

)

REST Syntax

POST http://demo.splendidcrm.com/Rest.svc/GetUserProfile

Parameters

None.

Return Value

Type: System.String

{"d":

{"__type":"Rest.UserProfile:#SplendidCRM"

,"TEAM_ID":"17bb7135-2b95-42dc-85de-842caff927a0"

,"TEAM_NAME":"Global"

,"USER_DATE_FORMAT":"MM\/dd\/yyyy"

,"USER_ID":"00000000-0000-0000-0003-000000000000"

,"USER_LANG":"en-US"

,"USER_NAME":"will"

,"USER_TIME_FORMAT":"h:mm tt"

}

}

Remarks

The language is important because it is used to get the correct terminology data.  The data includes lists.


Login

Performs user authentication and session initialization.

C# Syntax

public Guid Login

( string UserName

, string Password

, string Version

)

REST Syntax

POST http://demo.splendidcrm.com/Rest.svc/Login

Parameters

UserName

Type: System.String

Password

Type: System.String
The password is in plain text, so it is advisable that a secure channel is used when connecting to the server.

Version

Type: System.String
The Version is not used at this time, but is intended to be used to restrict functionality based on the version of the client.

Return Value

Type: System.Guid

{"d":"00000000-0000-0000-0003-000000000000"}

Remarks

This function is very similar to the web application login in the way that it authenticates a user and initializes the session.  If successful, this function will return the User ID. 

This method will throw an exception if the login fails.

{"ExceptionDetail":

      {"HelpLink":null

      ,"InnerException":null

      ,"Message":"Invalid username and\/or password for will"

      ,"StackTrace":"   at SplendidCRM.Rest.Login(String UserName, String Password, String Version) ..."

      ,"Type":"System.Exception"

      }

,"ExceptionType":"System.Exception"

,"Message":"Invalid username and\/or password for will"

,"StackTrace":"   at SplendidCRM.Rest.Login(String UserName, String Password, String Version) ..."

}


Logout

Performs a user logout.

C# Syntax

public void Logout

(

)

REST Syntax

POST http://demo.splendidcrm.com/Rest.svc/Logout

Parameters

None.

Return Value

None.

{"d":null}

Remarks

.


GetCustomList

Most lists come from the Terminology table.  Those that do not are custom lists.  Examples include Currencies, Releases, and Contract Types.

C# Syntax

public Stream GetCustomList

( string   ListName

)

REST Syntax

GET http://localhost/SplendidCRM6/Rest.svc/GetCustomList?ListName=Currencies

Parameters

ListName

Type: System.String

Return Value

Type: System.IO.Stream

{"d":

      {"results":

        

      }

      ,"__count":"3"

}

Remarks

.


GetModuleTable

Gets module table data.  This method is generally used for system tables such as the CONFIG table.

C# Syntax

public Stream GetModuleTable

( string   TableName

)

REST Syntax

Parameters

TableName

Type: System.String

Return Value

Type: System.IO.Stream

{"d":

      {"results":

        

      }

      ,"__count":"1"

}

Remarks

The SplendidCRM REST API uses an OData-like syntax that includes attributes such as $select and $orderby.


GetModuleList

GetModuleList is the primary method of retrieving records for a specified module.  The method accepts an OData-like syntax to allow the selection of fields, the ordering of the data and the filtering of the data.

C# Syntax

public Stream GetModuleList

( string   ModuleName

)

REST Syntax

Parameters

ModuleName

Type: System.String

Return Value

Type: System.IO.Stream

{"d":

      {"results":

       

      }

      ,"__count":"2"

}

Remarks

.


GetModuleItem

GetModuleItem is the primary method for retrieving all data for a specified module and ID.

C# Syntax

public Stream GetModuleItem

( string   ModuleName

, Guid     ID

)

REST Syntax

Parameters

ModuleName

Type: System.String

Return Value

Type: System.IO.Stream

{"d":

      {"results":

            {"__metadata":

                  {"uri":"http://demo.splendidcrm.com/Rest.svc/GetModuleItem?ModuleName=Contacts&ID=032d8ee7-ab2f-425b-ae38-ef54f8dcae38"

                  ,"type":"SplendidCRM.Contacts"

                  ,"etag":"032d8ee7-ab2f-425b-ae38-ef54f8dcae38.634609122677300000"

                  }

            ,"ID":"032d8ee7-ab2f-425b-ae38-ef54f8dcae38"

            ,"SALUTATION":"Mr."

            ,"NAME":"Bob Bobbins"

            ,"FIRST_NAME":"Bob"

            ,"LAST_NAME":"Bobbins"

            ,"LEAD_SOURCE":"Trade Show"

            ,"TITLE":"MD"

            ,"DEPARTMENT":null

            ,"REPORTS_TO_ID":null

            ,"REPORTS_TO_NAME":null

            ,"BIRTHDATE":"\\/Date(-62135596800000)\\/"

            ,"DO_NOT_CALL":false

            ,"PHONE_HOME":null

            ,"PHONE_MOBILE":null

            ,"PHONE_WORK":"01234 567890"

            ,"PHONE_OTHER":null

            ,"PHONE_FAX":null

            ,"EMAIL1":"bob@aol.com"

            ,"EMAIL2":null

            ,"ASSISTANT":null

            ,"ASSISTANT_PHONE":null

            ,"EMAIL_OPT_OUT":false

            ,"INVALID_EMAIL":false

            ,"PRIMARY_ADDRESS_STREET":"1 The Street"

            ,"PRIMARY_ADDRESS_CITY":"City"

            ,"PRIMARY_ADDRESS_STATE":"State"

            ,"PRIMARY_ADDRESS_POSTALCODE":"AB1 2CD"

            ,"PRIMARY_ADDRESS_COUNTRY":"UK"

            ,"ALT_ADDRESS_STREET":"1 The Street"

            ,"ALT_ADDRESS_CITY":"City"

            ,"ALT_ADDRESS_STATE":"State"

            ,"ALT_ADDRESS_POSTALCODE":"AB1 2CD"

            ,"ALT_ADDRESS_COUNTRY":"UK"

            ,"PORTAL_NAME":null

            ,"PORTAL_ACTIVE":false

            ,"PORTAL_APP":null

            ,"ASSIGNED_USER_ID":"00000000-0000-0000-0003-000000000000"

            ,"DATE_ENTERED":"\\/Date(1325297467640)\\/"

            ,"DATE_MODIFIED":"\\/Date(1325297467720)\\/"

            ,"DATE_MODIFIED_UTC":"\\/Date(1325315467730)\\/"

            ,"DESCRIPTION":"Hot lead!!"

            ,"TEAM_ID":"17bb7135-2b95-42dc-85de-842caff927a0"

            ,"TEAM_NAME":"Global"

            ,"ASSIGNED_TO":"will"

            ,"CREATED_BY":"will"

            ,"MODIFIED_BY":"will"

            ,"CREATED_BY_ID":"00000000-0000-0000-0003-000000000000"

            ,"MODIFIED_USER_ID":"00000000-0000-0000-0003-000000000000"

            ,"ACCOUNT_ID":null

            ,"ACCOUNT_NAME":null

            ,"ACCOUNT_ASSIGNED_USER_ID":null

            ,"TEAM_SET_ID":"e29b878a-640e-41f6-aad0-e6f62fc66e37"

            ,"TEAM_SET_NAME":"Global"

            ,"TEAM_SET_LIST":"17BB7135-2B95-42DC-85DE-842CAFF927A0"

            ,"ASSIGNED_TO_NAME":"Willy Wonka"

            ,"CREATED_BY_NAME":"Willy Wonka"

            ,"MODIFIED_BY_NAME":"Willy Wonka"

            ,"ID_C":"032d8ee7-ab2f-425b-ae38-ef54f8dcae38"

            }

      }

}

Remarks

This method will throw an exception if the user does not have edit access to the specified module.


UpdateModuleTable

This method is used to update relationship tables.

C# Syntax

public Guid UpdateModuleTable

( Stream    input

)

REST Syntax

POST http://demo.splendidcrm.com/Rest.svc/UpdateModuleTable

Parameters

input

Type: System.IO.Stream

Return Value

Type: System.Guid

 

Remarks

This method will throw an exception if the user does not have edit access to the specified module.


UpdateModule

UpdateModule is the primary method used to create or update data within the CRM.  It is used to update Accounts, Contacts, Leads, etc.

C# Syntax

public Guid UpdateModuleTable

( Stream    input

)

REST Syntax

Parameters

input

Type: System.IO.Stream

{"__metadata":

      {"uri":"http://demo.splendidcrm.com/Rest.svc/GetModuleItem?ModuleName=Contacts&ID=032d8ee7-ab2f-425b-ae38-ef54f8dcae38"

      ,"type":"SplendidCRM.Contacts"

      ,"etag":"032d8ee7-ab2f-425b-ae38-ef54f8dcae38.634609122677300000"

      }

,"ID":"032d8ee7-ab2f-425b-ae38-ef54f8dcae38"

,"SALUTATION":"Mr."

,"NAME":"Bob Bobbins"

,"FIRST_NAME":"Bob"

,"LAST_NAME":"Bobbins"

,"LEAD_SOURCE":"Trade Show"

,"TITLE":"MD"

,"DEPARTMENT":""

,"REPORTS_TO_ID":""

,"REPORTS_TO_NAME":null

,"BIRTHDATE":null

,"DO_NOT_CALL":false

,"PHONE_HOME":""

,"PHONE_MOBILE":""

,"PHONE_WORK":"01234 567890"

,"PHONE_OTHER":""

,"PHONE_FAX":""

,"EMAIL1":"bob@aol.com"

,"EMAIL2":""

,"ASSISTANT":""

,"ASSISTANT_PHONE":""

,"EMAIL_OPT_OUT":false

,"INVALID_EMAIL":false

,"PRIMARY_ADDRESS_STREET":"1 The Street"

,"PRIMARY_ADDRESS_CITY":"City"

,"PRIMARY_ADDRESS_STATE":"State"

,"PRIMARY_ADDRESS_POSTALCODE":"AB1 2CD"

,"PRIMARY_ADDRESS_COUNTRY":"UK"

,"ALT_ADDRESS_STREET":"1 The Street"

,"ALT_ADDRESS_CITY":"City"

,"ALT_ADDRESS_STATE":"State"

,"ALT_ADDRESS_POSTALCODE":"AB1 2CD"

,"ALT_ADDRESS_COUNTRY":"UK"

,"PORTAL_NAME":null

,"PORTAL_ACTIVE":false

,"PORTAL_APP":null

,"ASSIGNED_USER_ID":"00000000-0000-0000-0003-000000000000"

,"DATE_ENTERED":"\\/Date(1325297467640)\\/"

,"DATE_MODIFIED":"\\/Date(1325297467720)\\/"

,"DATE_MODIFIED_UTC":"\\/Date(1325315467730)\\/"

,"DESCRIPTION":"Hot lead!!"

,"TEAM_ID":"17BB7135-2B95-42DC-85DE-842CAFF927A0"

,"TEAM_NAME":"Global"

,"ASSIGNED_TO":"will"

,"CREATED_BY":"will"

,"MODIFIED_BY":"will"

,"CREATED_BY_ID":"00000000-0000-0000-0003-000000000000"

,"MODIFIED_USER_ID":"00000000-0000-0000-0003-000000000000"

,"ACCOUNT_ID":""

,"ACCOUNT_NAME":null

,"ACCOUNT_ASSIGNED_USER_ID":null

,"TEAM_SET_ID":"e29b878a-640e-41f6-aad0-e6f62fc66e37"

,"TEAM_SET_NAME":"Global"

,"TEAM_SET_LIST":"17BB7135-2B95-42DC-85DE-842CAFF927A0"

,"ASSIGNED_TO_NAME":"Willy Wonka"

,"CREATED_BY_NAME":"Willy Wonka"

,"MODIFIED_BY_NAME":"Willy Wonka"

,"ID_C":"032d8ee7-ab2f-425b-ae38-ef54f8dcae38"

}

Return Value

Type: System.Guid

{"d":"032d8ee7-ab2f-425b-ae38-ef54f8dcae38"}

Remarks

This method will throw an exception if the user does not have edit access to the specified module.


DeleteModuleItem

DeleteModuleItem is the primary method used to delete data within the CRM. 

C# Syntax

public void DeleteModuleItem

( String    ModuleName

, Guid      ID

)

REST Syntax

Parameters

input

Type: System.IO.Stream

{"ModuleName": "Contacts", "ID": "ecca024f-0081-40db-b6a9-1d95b1c36125"}

Return Value

None.

{"d":null}

Remarks

This method will throw an exception if the user does not have edit access to the specified module.


DeleteRelatedItem

DeleteRelatedItem is used to remove relationships between two modules. 

C# Syntax

public void DeleteRelatedItem

( String    ModuleName

, Guid      ID

, String    RelatedModule

, Guid      RelatedID

)

REST Syntax

Parameters

input

Type: System.IO.Stream

 

Return Value

None.

{"d":null}

Remarks

This method will throw an exception if the user does not have edit access to the specified modules.


Additional Information

The SplendidCRM Application Platform is constantly being improved.  Please visit the SplendidCRM Software website to obtain the most recent version of the software:

http://www.splendidcrm.com

If you have any questions, please post them to the SplendidCRM Support forum:

http://www.splendidcrm.com/Forums/tabid/66/Default.aspx

 

Errors and Omissions

If you discover any errors or omissions in this document, please email support@splendidcrm.com.