SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Andere mochten auch

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
 

Andere mochten auch (18)

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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 

Kürzlich hochgeladen (20)

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 

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

Hinweis der Redaktion

  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