SugarCRM Web Services API: Integrate Your Application With SugarCRM
Let's take a look at this brief article that explores SugarCRM web services and how to integrate your application with SugarCRM.
Join the DZone community and get the full member experience.
Join For FreeAs of 7.x, SOAP support is no longer offered with the new APIs. The legacy APIs are still accessible in the product, however, any existing integrations should be updated to use the latest REST endpoints of SugarCRM data migration. Web Services allow for communication between different applications and platforms. Sugar currently supports REST and SOAP APIs. The following sections will outline how to interact with the APIs and what versions of the API we recommend for use.
API versioning is the process of creating a new set of API endpoints for new functionality while leaving preexisting endpoints available for third-party applications and integrations to continue using. This helps to extend the application in an upgrade-safe manner.
When working with the Web Service API, you should be using the latest API specific to your release. A quick reference of this can be found below:
Release | REST Version | REST URL | SOAP Version | SOAP URL |
7.9.x | v10 | /rest/v10/ | v4.1 | /service/v4_1/soap.php |
7.8.x | v10 | /rest/v10/ | v4.1 | /service/v4_1/soap.php |
7.7.x | v10 | /rest/v10/ | v4.1 | /service/v4_1/soap.php |
6.5.x | v4.1 | /service/v4_1/rest.php | v4.1 | /service/v4_1/soap.php |
Best Practices When Integrating and Migrating Sugar
REST stands for "Representational State Transfer." As of 7.x, REST is a core component of Sugar that defines how all information is exchanged within the application. This v10 API is separate from the v2-v4_1 REST APIs in that it has been rebuilt with the latest REST standards. Most functionality in the system, whether fetching or posting data, is interacting with the API in some way.
How to Access the v10 REST Service
The base endpoint for the v10 REST service can be found at:
http://<site_url>/rest/v10/
For your reference, all v10 endpoints can be found by navigating to http://<site_url>/rest/v10/help
. Once you have identified your instance's base endpoint, we can begin by authenticating.
Authentication
Sugar 7 uses two-legged OAuth2 for authentication. You simply need to do a POST to /rest/v10/oauth2/token
with the following parameters:
grant_type | String | Type of request. Available grant types are "password" and "refresh_token". |
client_id | String | The client_id of "sugar" will automatically create an OAuth Key in the system and can be used for "password" authentication. The client_id of "support_portal" will create an OAuth Key if the portal system is enabled and will allow for portal authentication. Other client_id's can be created by the administrator in the OAuthKeys section in the Administration section and can be used in the future for additional grant types, if the client secret is filled in, it will be checked to validate use of the client id. |
client_secret | String | The client's secret key. |
username | String | The username of the user authenticating to the system. |
password | String | The plaintext password the user authenticating to the system. |
platform | String | Defaults to "base" allows you to have custom meta-data per platform. This parameter should be an identifiable string. Do not use random GUIDS or changing variables. Doing so may result in large ./cache directories. |
First, we are going to login using a grant_type
of "password" and a platform
of "custom." Normally, when logging into Sugar, users log in with a platform
type of "base". We are using "custom" to avoid any potential login conflicts.
curl -X POST -H Cache-Control:no-cache -d '{
"grant_type":"password",
"client_id":"sugar",
"client_secret":"",
"username":"<username>",
"password":"<password>",
"platform":"custom"
}' http:/<site_url>/rest/v10/oauth2/token
The SugarCRM integration allows you to create customer contacts, leads, or opportunities from ongoing or archived chats and save them in your SugarCRM. This API is not just an add-on integrating functions in sugar; it helps to empower your organization's goals.
Opinions expressed by DZone contributors are their own.
Comments