SlideShare une entreprise Scribd logo
1  sur  36
Using the SugarCRM
     REST API
About the Speaker
                         Asa
                         Kusuma
• Web Developer at Milsoft Utility Solutions
• Junior at Abilene Christian University
• Twitter: asakusuma
• asakusuma.com
What is a REST API?
• Web service
 • Allow external access to data
 • Some protocol for transferring data
• Representational State Transfer
• Transfer an object’s “state” across apps
• Encode with JSON, send using HTTPS
REST vs. SOAP
• REST               photo by superbomba




 • JSON
 • Less overhead
• SOAP
 • XML
 • More overhead
Web Services:
What’s the Big Deal?
photo by gerlos




                      www.photographyicon.com




Bridge apps with data
CRM needs external data

External apps need CRM data
Our Needs at Milsoft
•   Support Portal                photo by eBeam




    • Customers create and view cases
    • Add notes with attachments
• Customers update company data
• Give customers limited data access
End Goal:
Build a web app that
talks with SugarCRM
The End Goal Expanded
•   CRUD capability           photo by eBeam




•   PHP web app

    •   cURL Library

    •   JSON

    •   Wrapper class

•   Security            photo by Sprengben
The Big Picture
PHP App     SugarCRM

Model         Data



             REST API
The Big Picture
  PHP App      SugarCRM

   Model         Data



REST Wrapper
                REST API
    Class
The Big Picture
  PHP App             SugarCRM

   Model                Data

               API
               Call
REST Wrapper
                      REST API
    Class
Get the code

asakusuma.com/sugarcon/2011/
Ideal Code Example
                                           photo by eBeam
$sugar = new SugarREST();

$module = “Cases”;

$fields = array(‘id’,‘name’,‘status’);

$records = $sugar->get($module,$fields);

foreach($records as $record) {

    echo $record[‘name’];

}
But first, some REST API basics
What’s an API Call?
• Request to create, read, update, or delete
• API responds with data or confirmation
• 3 Parts
 • Method = Specify what to do
 • Arguments = Specify details
 • API Response = What happened
API Call Example

• Create a new Contact
• Method = set_entry
• Arguments = New Contact data
• Response = ID of newly created Contact
JSON Primer
array(
                           photo by eBeam


    ‘name’ => ‘Robert’,

    ‘children’ => array(

        ‘Chris’,

        ‘Anne’,

        ‘Bob’

    )

)
JSON Primer (cont.)
{
                       photo by eBeam


    “name”:“Robert”,

    “children” : {

        0:“Chris”,

        1:“Anne”,

        2:“Bob”

    }

}
JSON Primer (cont.)
                                  photo by eBeam




$my_array = array(1,2,3);

$my_json_str = json_encode($my_array);

$my_array = json_decode($my_json_string);

//$my_array remains unchanged
Making REST API Calls

• https://mysite.com/sugarcrm/service/v2/rest.php
• Method name
• Arguments (JSON)
• Input type
• Response type
Example POST Data

method=login&
input_type=json&
response_type=json&
rest_data={"name": “value”}
Implemented in PHP
$ch = curl_init();


curl_setopt($ch, CURLOPT_URL, $rest_api_url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);


curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);


$output = json_decode(curl_exec($ch));
Authentication
1. Make “Login” REST call                photo by eBeam




2. Receive session ID

3. Use session ID to authenticate other calls

4. Make “Logout” REST call with session ID

5. Use HTTPS
Example: Modify Contact
Modify Contact (cont.)
$arguments = array(
     'session' => $session_id,
	 'module_name' => 'Contacts',
	 'name_value_list' => array(
          'id'=>'9hg5a93a-2dfdf-d6pe-1oq4-cjqic4mxok',
          'title'=>'REST API Guy'
     )
);
Modify Contact (cont.)
$post_data   = "method=set_entry&";
$post_data .= "input_type=json&";
$post_data .= "response_type=json&";
$post_data .= "rest_data=".json_encode($arguments);
	 	
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $rest_api_url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$output = json_decode(curl_exec($ch));
REST Wrapper Class
1. Download: asakusuma.com/sugarcon/2011/code
  • example.php
  • sugar_rest.php
  • README.markdown
2. Read the README (it’s there for a reason)
3. Configure sugar_rest.php
4. Run the example
Important Functions
set() is for both create and update operations

set($module, $fields, $options);
get($module, $fields, $options);
get_with_related($module, $fields,
$options);
Note Functions
• set_note_attachment()
• get_note_attachment()
• Use binary data
• Arguments are a little complicated
• Use documentation in the README
Things to Keep in Mind

• You must specify a query LIMIT
• Different output format for get() and
  get_with_related()
• Wrapper doesn’t include delete
• Use HTTPS
Security
                                photo by maistora




•   Protect your data

•   Weakest link

•   REST API = liability

•   Use caution when
    mapping URL to data
photo by gerlos




Leverage your data.
                       www.photographyicon.com




Connect your apps.
Presentation + Code at
asakusuma.com/sugarcon/2011
   Questions? Comments?
  asa.kusuma@milsoft.com
     Twitter: asakusuma
       Official Docs at
  developers.sugarcrm.com

Contenu connexe

Tendances

Adapt or Die: A Microservices Story at Google
Adapt or Die: A Microservices Story at GoogleAdapt or Die: A Microservices Story at Google
Adapt or Die: A Microservices Story at GoogleApigee | Google Cloud
 
Is it time to migrate to Vue 3?
Is it time to migrate to Vue 3?Is it time to migrate to Vue 3?
Is it time to migrate to Vue 3?Denny Biasiolli
 
Gitlab CI : Integration et Déploiement Continue
Gitlab CI : Integration et Déploiement ContinueGitlab CI : Integration et Déploiement Continue
Gitlab CI : Integration et Déploiement ContinueVincent Composieux
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & GitJason Byrne
 
Application Spring MVC/IOC & Hibernate
Application Spring MVC/IOC & HibernateApplication Spring MVC/IOC & Hibernate
Application Spring MVC/IOC & HibernateInes Ouaz
 
YAML Tips For Kubernetes by Neependra Khare
YAML Tips For Kubernetes by Neependra KhareYAML Tips For Kubernetes by Neependra Khare
YAML Tips For Kubernetes by Neependra KhareCodeOps Technologies LLP
 
Resilient microservices with Kubernetes - Mete Atamel - Codemotion Rome 2017
Resilient microservices with Kubernetes - Mete Atamel - Codemotion Rome 2017Resilient microservices with Kubernetes - Mete Atamel - Codemotion Rome 2017
Resilient microservices with Kubernetes - Mete Atamel - Codemotion Rome 2017Codemotion
 
Exactly once with spark streaming
Exactly once with spark streamingExactly once with spark streaming
Exactly once with spark streamingQuentin Ambard
 
Notes de cours et tp - Administation Systèmes
Notes de cours et tp  - Administation Systèmes Notes de cours et tp  - Administation Systèmes
Notes de cours et tp - Administation Systèmes Ikram Benabdelouahab
 
Inside Flutter: Widgets, Elements, and RenderObjects
Inside Flutter: Widgets, Elements, and RenderObjectsInside Flutter: Widgets, Elements, and RenderObjects
Inside Flutter: Widgets, Elements, and RenderObjectsHansol Lee
 
Linux - Hedi Magroun - AUF - 2008
Linux -  Hedi Magroun - AUF - 2008Linux -  Hedi Magroun - AUF - 2008
Linux - Hedi Magroun - AUF - 2008Hedi Magroun
 
Asynchronous API in Java8, how to use CompletableFuture
Asynchronous API in Java8, how to use CompletableFutureAsynchronous API in Java8, how to use CompletableFuture
Asynchronous API in Java8, how to use CompletableFutureJosé Paumard
 
Building Value - Understanding the TCO and ROI of Apache Kafka & Confluent
Building Value  - Understanding the TCO and ROI of Apache Kafka & ConfluentBuilding Value  - Understanding the TCO and ROI of Apache Kafka & Confluent
Building Value - Understanding the TCO and ROI of Apache Kafka & Confluentconfluent
 

Tendances (20)

Adapt or Die: A Microservices Story at Google
Adapt or Die: A Microservices Story at GoogleAdapt or Die: A Microservices Story at Google
Adapt or Die: A Microservices Story at Google
 
Is it time to migrate to Vue 3?
Is it time to migrate to Vue 3?Is it time to migrate to Vue 3?
Is it time to migrate to Vue 3?
 
Circuit Breaker.pptx
Circuit Breaker.pptxCircuit Breaker.pptx
Circuit Breaker.pptx
 
Gitlab CI : Integration et Déploiement Continue
Gitlab CI : Integration et Déploiement ContinueGitlab CI : Integration et Déploiement Continue
Gitlab CI : Integration et Déploiement Continue
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & Git
 
Kubernetes
KubernetesKubernetes
Kubernetes
 
Application Spring MVC/IOC & Hibernate
Application Spring MVC/IOC & HibernateApplication Spring MVC/IOC & Hibernate
Application Spring MVC/IOC & Hibernate
 
YAML Tips For Kubernetes by Neependra Khare
YAML Tips For Kubernetes by Neependra KhareYAML Tips For Kubernetes by Neependra Khare
YAML Tips For Kubernetes by Neependra Khare
 
Jenkins CI presentation
Jenkins CI presentationJenkins CI presentation
Jenkins CI presentation
 
Resilient microservices with Kubernetes - Mete Atamel - Codemotion Rome 2017
Resilient microservices with Kubernetes - Mete Atamel - Codemotion Rome 2017Resilient microservices with Kubernetes - Mete Atamel - Codemotion Rome 2017
Resilient microservices with Kubernetes - Mete Atamel - Codemotion Rome 2017
 
Exactly once with spark streaming
Exactly once with spark streamingExactly once with spark streaming
Exactly once with spark streaming
 
Jenkins
JenkinsJenkins
Jenkins
 
Git
GitGit
Git
 
Spring ioc
Spring iocSpring ioc
Spring ioc
 
Notes de cours et tp - Administation Systèmes
Notes de cours et tp  - Administation Systèmes Notes de cours et tp  - Administation Systèmes
Notes de cours et tp - Administation Systèmes
 
Inside Flutter: Widgets, Elements, and RenderObjects
Inside Flutter: Widgets, Elements, and RenderObjectsInside Flutter: Widgets, Elements, and RenderObjects
Inside Flutter: Widgets, Elements, and RenderObjects
 
Linux - Hedi Magroun - AUF - 2008
Linux -  Hedi Magroun - AUF - 2008Linux -  Hedi Magroun - AUF - 2008
Linux - Hedi Magroun - AUF - 2008
 
Asynchronous API in Java8, how to use CompletableFuture
Asynchronous API in Java8, how to use CompletableFutureAsynchronous API in Java8, how to use CompletableFuture
Asynchronous API in Java8, how to use CompletableFuture
 
MicroK8s
MicroK8sMicroK8s
MicroK8s
 
Building Value - Understanding the TCO and ROI of Apache Kafka & Confluent
Building Value  - Understanding the TCO and ROI of Apache Kafka & ConfluentBuilding Value  - Understanding the TCO and ROI of Apache Kafka & Confluent
Building Value - Understanding the TCO and ROI of Apache Kafka & Confluent
 

En vedette

Easy Integration of your external systems with SugarCRM
Easy Integration of your external systems with SugarCRMEasy Integration of your external systems with SugarCRM
Easy Integration of your external systems with SugarCRMSugarCRM
 
Practical JavaScript Promises
Practical JavaScript PromisesPractical JavaScript Promises
Practical JavaScript PromisesAsa Kusuma
 
How to Build a Java client for SugarCRM
How to Build a Java client for SugarCRMHow to Build a Java client for SugarCRM
How to Build a Java client for SugarCRMAntonio Musarra
 
Sugar U: Session 4: Using SugarCRM as a Project Development Platform
Sugar U: Session 4: Using SugarCRM as a Project Development Platform Sugar U: Session 4: Using SugarCRM as a Project Development Platform
Sugar U: Session 4: Using SugarCRM as a Project Development Platform SugarCRM
 
OKRy - co to jest i jak wdrożyć w organizacji
OKRy - co to jest i jak wdrożyć w organizacjiOKRy - co to jest i jak wdrożyć w organizacji
OKRy - co to jest i jak wdrożyć w organizacjiTomasz Bienias
 
開発プラットフォームとしてのSugarCRM
開発プラットフォームとしてのSugarCRM開発プラットフォームとしてのSugarCRM
開発プラットフォームとしてのSugarCRMOSSラボ株式会社
 
Prioritizing Portfolio Backlog to Maximize Value Steve Mayner Agile Asia 2016
Prioritizing Portfolio Backlog to Maximize Value Steve Mayner Agile Asia 2016Prioritizing Portfolio Backlog to Maximize Value Steve Mayner Agile Asia 2016
Prioritizing Portfolio Backlog to Maximize Value Steve Mayner Agile Asia 2016gmaran23
 
Connecting the Clouds to Drive the Customer Journey
Connecting the Clouds to Drive the Customer JourneyConnecting the Clouds to Drive the Customer Journey
Connecting the Clouds to Drive the Customer JourneySalesforce Marketing Cloud
 
Getting the Most Out of Microsoft Dynamics CRM Integrations
Getting the Most Out of Microsoft Dynamics CRM IntegrationsGetting the Most Out of Microsoft Dynamics CRM Integrations
Getting the Most Out of Microsoft Dynamics CRM IntegrationsSalesforce Marketing Cloud
 
Group Writing Sample - Business Proposal
Group Writing Sample - Business ProposalGroup Writing Sample - Business Proposal
Group Writing Sample - Business ProposalNatasha Fleury
 
Mi carta a los ciudadanos xxiii 15ene2014
Mi carta a los ciudadanos xxiii 15ene2014 Mi carta a los ciudadanos xxiii 15ene2014
Mi carta a los ciudadanos xxiii 15ene2014 Runrunes
 
Repercusión mediática Football Transfer Review 2011
Repercusión mediática Football Transfer Review 2011Repercusión mediática Football Transfer Review 2011
Repercusión mediática Football Transfer Review 2011Prime Time Sport
 
Ley 962 ley de accesibilidad
Ley 962 ley de accesibilidadLey 962 ley de accesibilidad
Ley 962 ley de accesibilidadfelipebaside
 

En vedette (19)

Easy Integration of your external systems with SugarCRM
Easy Integration of your external systems with SugarCRMEasy Integration of your external systems with SugarCRM
Easy Integration of your external systems with SugarCRM
 
SugarCRM Integration
SugarCRM IntegrationSugarCRM Integration
SugarCRM Integration
 
Practical JavaScript Promises
Practical JavaScript PromisesPractical JavaScript Promises
Practical JavaScript Promises
 
How to Build a Java client for SugarCRM
How to Build a Java client for SugarCRMHow to Build a Java client for SugarCRM
How to Build a Java client for SugarCRM
 
Sugar U: Session 4: Using SugarCRM as a Project Development Platform
Sugar U: Session 4: Using SugarCRM as a Project Development Platform Sugar U: Session 4: Using SugarCRM as a Project Development Platform
Sugar U: Session 4: Using SugarCRM as a Project Development Platform
 
OKRy - co to jest i jak wdrożyć w organizacji
OKRy - co to jest i jak wdrożyć w organizacjiOKRy - co to jest i jak wdrożyć w organizacji
OKRy - co to jest i jak wdrożyć w organizacji
 
Raport
Raport Raport
Raport
 
開発プラットフォームとしてのSugarCRM
開発プラットフォームとしてのSugarCRM開発プラットフォームとしてのSugarCRM
開発プラットフォームとしてのSugarCRM
 
Prioritizing Portfolio Backlog to Maximize Value Steve Mayner Agile Asia 2016
Prioritizing Portfolio Backlog to Maximize Value Steve Mayner Agile Asia 2016Prioritizing Portfolio Backlog to Maximize Value Steve Mayner Agile Asia 2016
Prioritizing Portfolio Backlog to Maximize Value Steve Mayner Agile Asia 2016
 
Connecting the Clouds to Drive the Customer Journey
Connecting the Clouds to Drive the Customer JourneyConnecting the Clouds to Drive the Customer Journey
Connecting the Clouds to Drive the Customer Journey
 
Getting the Most Out of Microsoft Dynamics CRM Integrations
Getting the Most Out of Microsoft Dynamics CRM IntegrationsGetting the Most Out of Microsoft Dynamics CRM Integrations
Getting the Most Out of Microsoft Dynamics CRM Integrations
 
Group Writing Sample - Business Proposal
Group Writing Sample - Business ProposalGroup Writing Sample - Business Proposal
Group Writing Sample - Business Proposal
 
Presentation
PresentationPresentation
Presentation
 
Modelo de solicitud de colegios
Modelo de solicitud de colegiosModelo de solicitud de colegios
Modelo de solicitud de colegios
 
Mi carta a los ciudadanos xxiii 15ene2014
Mi carta a los ciudadanos xxiii 15ene2014 Mi carta a los ciudadanos xxiii 15ene2014
Mi carta a los ciudadanos xxiii 15ene2014
 
Repercusión mediática Football Transfer Review 2011
Repercusión mediática Football Transfer Review 2011Repercusión mediática Football Transfer Review 2011
Repercusión mediática Football Transfer Review 2011
 
Ley 962 ley de accesibilidad
Ley 962 ley de accesibilidadLey 962 ley de accesibilidad
Ley 962 ley de accesibilidad
 
TLSFD - presenters
TLSFD - presentersTLSFD - presenters
TLSFD - presenters
 
Claudio Adrian Natoli - Periodismo digital
Claudio Adrian Natoli - Periodismo digitalClaudio Adrian Natoli - Periodismo digital
Claudio Adrian Natoli - Periodismo digital
 

Similaire à Using the SugarCRM REST API

Web Apps for the Masses
Web Apps for the MassesWeb Apps for the Masses
Web Apps for the MassesDavid Tufts
 
Crafting Evolvable Api Responses
Crafting Evolvable Api ResponsesCrafting Evolvable Api Responses
Crafting Evolvable Api Responsesdarrelmiller71
 
MongoDB.local Dallas 2019: Pissing Off IT and Delivery: A Tale of 2 ODS's
MongoDB.local Dallas 2019: Pissing Off IT and Delivery: A Tale of 2 ODS'sMongoDB.local Dallas 2019: Pissing Off IT and Delivery: A Tale of 2 ODS's
MongoDB.local Dallas 2019: Pissing Off IT and Delivery: A Tale of 2 ODS'sMongoDB
 
RESTful API-centric Universe
RESTful API-centric UniverseRESTful API-centric Universe
RESTful API-centric UniverseTihomir Opačić
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformAntonio Peric-Mazar
 
API-first development
API-first developmentAPI-first development
API-first developmentVasco Veloso
 
Web Services PHP Tutorial
Web Services PHP TutorialWeb Services PHP Tutorial
Web Services PHP TutorialLorna Mitchell
 
Painless Persistence in a Disconnected World
Painless Persistence in a Disconnected WorldPainless Persistence in a Disconnected World
Painless Persistence in a Disconnected WorldChristian Melchior
 
From System Engineer to Gopher
From System Engineer to GopherFrom System Engineer to Gopher
From System Engineer to GopherI-Fan Wang
 
Rethinking Syncing at AltConf 2019
Rethinking Syncing at AltConf 2019Rethinking Syncing at AltConf 2019
Rethinking Syncing at AltConf 2019Joe Keeley
 
Austin Day of Rest - Introduction
Austin Day of Rest - IntroductionAustin Day of Rest - Introduction
Austin Day of Rest - IntroductionHandsOnWP.com
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsCarol McDonald
 
WordPress APIs
WordPress APIsWordPress APIs
WordPress APIsmdawaffe
 
I Love APIs Europe 2015: Developer Sessions
I Love APIs Europe 2015: Developer SessionsI Love APIs Europe 2015: Developer Sessions
I Love APIs Europe 2015: Developer SessionsApigee | Google Cloud
 
Ember Data and JSON API
Ember Data and JSON APIEmber Data and JSON API
Ember Data and JSON APIyoranbe
 
Consuming RESTful Web services in PHP
Consuming RESTful Web services in PHPConsuming RESTful Web services in PHP
Consuming RESTful Web services in PHPZoran Jeremic
 
Consuming RESTful services in PHP
Consuming RESTful services in PHPConsuming RESTful services in PHP
Consuming RESTful services in PHPZoran Jeremic
 

Similaire à Using the SugarCRM REST API (20)

Web Apps for the Masses
Web Apps for the MassesWeb Apps for the Masses
Web Apps for the Masses
 
Crafting Evolvable Api Responses
Crafting Evolvable Api ResponsesCrafting Evolvable Api Responses
Crafting Evolvable Api Responses
 
MongoDB.local Dallas 2019: Pissing Off IT and Delivery: A Tale of 2 ODS's
MongoDB.local Dallas 2019: Pissing Off IT and Delivery: A Tale of 2 ODS'sMongoDB.local Dallas 2019: Pissing Off IT and Delivery: A Tale of 2 ODS's
MongoDB.local Dallas 2019: Pissing Off IT and Delivery: A Tale of 2 ODS's
 
RESTful API-centric Universe
RESTful API-centric UniverseRESTful API-centric Universe
RESTful API-centric Universe
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
 
API-first development
API-first developmentAPI-first development
API-first development
 
REST API for your WP7 App
REST API for your WP7 AppREST API for your WP7 App
REST API for your WP7 App
 
ApacheCon 2005
ApacheCon 2005ApacheCon 2005
ApacheCon 2005
 
Web Services PHP Tutorial
Web Services PHP TutorialWeb Services PHP Tutorial
Web Services PHP Tutorial
 
Painless Persistence in a Disconnected World
Painless Persistence in a Disconnected WorldPainless Persistence in a Disconnected World
Painless Persistence in a Disconnected World
 
From System Engineer to Gopher
From System Engineer to GopherFrom System Engineer to Gopher
From System Engineer to Gopher
 
Rethinking Syncing at AltConf 2019
Rethinking Syncing at AltConf 2019Rethinking Syncing at AltConf 2019
Rethinking Syncing at AltConf 2019
 
Austin Day of Rest - Introduction
Austin Day of Rest - IntroductionAustin Day of Rest - Introduction
Austin Day of Rest - Introduction
 
Rest
RestRest
Rest
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.js
 
WordPress APIs
WordPress APIsWordPress APIs
WordPress APIs
 
I Love APIs Europe 2015: Developer Sessions
I Love APIs Europe 2015: Developer SessionsI Love APIs Europe 2015: Developer Sessions
I Love APIs Europe 2015: Developer Sessions
 
Ember Data and JSON API
Ember Data and JSON APIEmber Data and JSON API
Ember Data and JSON API
 
Consuming RESTful Web services in PHP
Consuming RESTful Web services in PHPConsuming RESTful Web services in PHP
Consuming RESTful Web services in PHP
 
Consuming RESTful services in PHP
Consuming RESTful services in PHPConsuming RESTful services in PHP
Consuming RESTful services in PHP
 

Dernier

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Dernier (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

Using the SugarCRM REST API

  • 2. About the Speaker Asa Kusuma • Web Developer at Milsoft Utility Solutions • Junior at Abilene Christian University • Twitter: asakusuma • asakusuma.com
  • 3. What is a REST API? • Web service • Allow external access to data • Some protocol for transferring data • Representational State Transfer • Transfer an object’s “state” across apps • Encode with JSON, send using HTTPS
  • 4. REST vs. SOAP • REST photo by superbomba • JSON • Less overhead • SOAP • XML • More overhead
  • 6. photo by gerlos www.photographyicon.com Bridge apps with data
  • 7. CRM needs external data External apps need CRM data
  • 8. Our Needs at Milsoft • Support Portal photo by eBeam • Customers create and view cases • Add notes with attachments • Customers update company data • Give customers limited data access
  • 9.
  • 10. End Goal: Build a web app that talks with SugarCRM
  • 11. The End Goal Expanded • CRUD capability photo by eBeam • PHP web app • cURL Library • JSON • Wrapper class • Security photo by Sprengben
  • 12. The Big Picture PHP App SugarCRM Model Data REST API
  • 13. The Big Picture PHP App SugarCRM Model Data REST Wrapper REST API Class
  • 14. The Big Picture PHP App SugarCRM Model Data API Call REST Wrapper REST API Class
  • 16. Ideal Code Example photo by eBeam $sugar = new SugarREST(); $module = “Cases”; $fields = array(‘id’,‘name’,‘status’); $records = $sugar->get($module,$fields); foreach($records as $record) { echo $record[‘name’]; }
  • 17. But first, some REST API basics
  • 18. What’s an API Call? • Request to create, read, update, or delete • API responds with data or confirmation • 3 Parts • Method = Specify what to do • Arguments = Specify details • API Response = What happened
  • 19. API Call Example • Create a new Contact • Method = set_entry • Arguments = New Contact data • Response = ID of newly created Contact
  • 20. JSON Primer array( photo by eBeam ‘name’ => ‘Robert’, ‘children’ => array( ‘Chris’, ‘Anne’, ‘Bob’ ) )
  • 21. JSON Primer (cont.) { photo by eBeam “name”:“Robert”, “children” : { 0:“Chris”, 1:“Anne”, 2:“Bob” } }
  • 22. JSON Primer (cont.) photo by eBeam $my_array = array(1,2,3); $my_json_str = json_encode($my_array); $my_array = json_decode($my_json_string); //$my_array remains unchanged
  • 23. Making REST API Calls • https://mysite.com/sugarcrm/service/v2/rest.php • Method name • Arguments (JSON) • Input type • Response type
  • 25. Implemented in PHP $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $rest_api_url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); $output = json_decode(curl_exec($ch));
  • 26. Authentication 1. Make “Login” REST call photo by eBeam 2. Receive session ID 3. Use session ID to authenticate other calls 4. Make “Logout” REST call with session ID 5. Use HTTPS
  • 28. Modify Contact (cont.) $arguments = array( 'session' => $session_id, 'module_name' => 'Contacts', 'name_value_list' => array( 'id'=>'9hg5a93a-2dfdf-d6pe-1oq4-cjqic4mxok', 'title'=>'REST API Guy' ) );
  • 29. Modify Contact (cont.) $post_data = "method=set_entry&"; $post_data .= "input_type=json&"; $post_data .= "response_type=json&"; $post_data .= "rest_data=".json_encode($arguments); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $rest_api_url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); $output = json_decode(curl_exec($ch));
  • 30. REST Wrapper Class 1. Download: asakusuma.com/sugarcon/2011/code • example.php • sugar_rest.php • README.markdown 2. Read the README (it’s there for a reason) 3. Configure sugar_rest.php 4. Run the example
  • 31. Important Functions set() is for both create and update operations set($module, $fields, $options); get($module, $fields, $options); get_with_related($module, $fields, $options);
  • 32. Note Functions • set_note_attachment() • get_note_attachment() • Use binary data • Arguments are a little complicated • Use documentation in the README
  • 33. Things to Keep in Mind • You must specify a query LIMIT • Different output format for get() and get_with_related() • Wrapper doesn’t include delete • Use HTTPS
  • 34. Security photo by maistora • Protect your data • Weakest link • REST API = liability • Use caution when mapping URL to data
  • 35. photo by gerlos Leverage your data. www.photographyicon.com Connect your apps.
  • 36. Presentation + Code at asakusuma.com/sugarcon/2011 Questions? Comments? asa.kusuma@milsoft.com Twitter: asakusuma Official Docs at developers.sugarcrm.com

Notes de l'éditeur

  1. \n
  2. milsoft\ncomputer science major\nopen source web development and clean web design\n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n