Introduction to the Sugar 7 API Wrapper Class

In a previous post I showed you how to use Guzzle to interact with the new SugarCRM v10 API. Today, I would like to introduce you to an even easier way to utilize the new API, the SugarCRM REST API Wrapper Class.

Installation and Instantiation

Installation of this package is handled with Composer. Start by updating composer.json with the following information.

Next, install the package via Composer.

With the SugarCRM REST API Wrapper installed and auto loaded, we can now instantiate the class and authenticate against our SugarCRM instance.

 

Common Usage Examples

1. Searching for an account by Name.

2. Alternatively, we can retrieve an account by ID.

3. Retrieving a list of cases associated to an account.

4. Create a case and relate the case to an account.

5. Listing notes associated to a case.

6. Listing documents associated to the account. (Compare to using Guzzle without the wrapper class)

 

Summary

There you have it. Using this new wrapper class is very simple and involves much less code than using cURL or even Guzzle to interact with the new API. That said, the wrapper class requires Guzzle and will install it via composer for you.

Are there any other examples you would like to see? If so, please comment and I’ll update this post accordingly.

3 thoughts on “Introduction to the Sugar 7 API Wrapper Class

  1. Thanks for such a resourceful article! I have a question: Can I use this Sugar 7 API Wrapper Class to invoke “Accounts” related tasks? So along with creating & updating “Contacts” in SugarCRM, I also want to create & update “Accounts”, assign a contact under designated account and sort of stuffs. Your insights on how to do it are highly appreciated :)

  2. Hi Sean Pinegar, I tried installing spinegar/sugar7wrapper in my laravel but it is giving me an error:

    - Installation request for spinegar/sugar7wrapper dev-master -> satisfiable by spinegar/sugar7wrapper[dev-master].
    - spinegar/sugar7wrapper dev-master requires guzzle/guzzle v3.8.1 -> no matching package found.

    The fact is that I have already installed guzzle//guzzle v3.9 (more updated & stable version) but I am unable to install spinegar/sugar7wrapper.

    Please can you tell me how can I install it meeting the pre-installation requisites?
    Thanks in advance!

  3. I am getting error

    Fatal error: Uncaught Guzzle\Http\Exception\ClientErrorResponseException: Client error response [status code] 404 [reason phrase] Not Found [url] http://localhost:8080/crm/rest/v10/oauth2/token in C:\xampp\htdocs\crmapi\vendor\guzzle\guzzle\src\Guzzle\Http\Exception\BadResponseException.php:43 Stack trace: #0 C:\xampp\htdocs\crmapi\vendor\guzzle\guzzle\src\Guzzle\Http\Message\Request.php(145): Guzzle\Http\Exception\BadResponseException::factory(Object(Guzzle\Http\Message\EntityEnclosingRequest), Object(Guzzle\Http\Message\Response)) #1 [internal function]: Guzzle\Http\Message\Request::onRequestError(Object(Guzzle\Common\Event), ‘request.error’, Object(Symfony\Component\EventDispatcher\EventDispatcher)) #2 C:\xampp\htdocs\crmapi\vendor\symfony\event-dispatcher\EventDispatcher.php(212): call_user_func(Array, Object(Guzzle\Common\Event), ‘request.error’, Object(Symfony\Component\EventDispatcher\EventDispatcher)) #3 C:\xampp\htdocs\crmapi\vendor\symfony\event-dispatcher\EventDispatcher.php(44): Symfony\Component\EventDispa in C:\xampp\htdocs\crmapi\vendor\guzzle\guzzle\src\Guzzle\Http\Exception\BadResponseException.php on line 43

    Please tell me how to fix?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Current day month ye@r *