Fast Path To B2C Commerce Developer Certification - Module 6 - OCAPI and Service Framework
Fast Path To B2C Commerce Developer Certification - Module 6 - OCAPI and Service Framework
Developer Certification
• Objective - By the end of this module you will be able to a use an OCAPI resource to
retrieve Custom Objects from a site
• This module will cover:
• OCAPI basics
• OCAPI resource setup
• Using Postman to authorize against a SB and retrieve COs
• What is this functionality and why does it matter for implementations?
• OCAPI is the current API available for realtime access by 3rd party systems
• OCAPI allows front-end applications written in other languages to access the B2C
Commerce data
• Postman is a useful tool to test your OCAPI configuration and performance
What is OCAPI?
AKA Open Commerce APIs
RESTful API that consists of three components APIs:
● Shop API – used for storefront-like interactions (e.g. from a mobile app)
● Data API – used for server-to-server integrations (e.g. OMS pushing order status)
● Meta API – used for getting information about the available OCAPI resources
Sample usages of OCAPI APIs
Control OCAPI client id permissions and also the caching of various OCAPI resources.
Done from Administration > Site Development > Open Commerce API Settings
The settings start with JSON document format version identifier, it is the format of the
configuration, it does NOT limit the calls to that specific version.
More information about the configuration is available in:
https://documentation.b2c.commercecloud.salesforce.com/DOC1/topic/com.demandware.dochelp
/OCAPI/current/usage/OCAPISettings.html
It is possible to limit the resource properties visible for a particular client:
https://documentation.b2c.commercecloud.salesforce.com/DOC1/topic/com.demandware.dochelp
/OCAPI/current/usage/PropertySelection.html
Client ID
Client ID is needed for all OCAPI calls and is configured in Account Manager
https://documentation.b2c.commercecloud.salesforce.com/DOC1/topic/com.demandware.dochelp
/AccountManager/AccountManagerAddAPIClientID.html
Once client ID is configured and enabled in Account Manager, it is needed to do corresponding
configuration about resource-level access that this client id will have to various OCAPI resources.
Such configuration is also needed on your sandboxes: use the 30 a’s client id in your settings:
"client_id":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
Using Postman as a tool to learn OCAPI
• Objective - By the end of this module you will be able to a understand the Web
Services Framework
• This module will cover:
• Web service basics
• Configuration in Business Manager
• Coding your web service
• Why does this functionality matter for implementations?
• Web services are required to connect to 3rd party systems (i.e. payment)
• By using the framework, you can take advantage of pre-built throttling and
monitoring capabilities
What is the Web Services Framework?
AKA Services
B2C Commerce provides a web service framework to make it easier to manage RESTful and
SOAP calls to 3rd party systems.
The framework helps you:
● Manage calls to web services
● Analyze service performance by collecting analytics on your web service calls
The framework enforces limits that you configure:
● Limits on the overall number of calls allowed in a time interval
● Limits on the number of failed calls allowed in a time interval
Steps to set up a Web Service
The profile specifies if you want to enable timeout, circuit breaker, and rate limit on the service.
Great explanation of breaker and rate limit here.
Configure Service Credential in Business Manager
Navigate to Administration > Operations > Services > Credentials tab
These settings specify the endpoint, username and password to connect to the service.
Also, any custom attributes required for the connection can be specified here.
Code your web service
1. Create an SFRA version of the HTTP web service code reviewed during the demo.
2. Create a new job with a custom step that calls your new SFRA web service. Remember
to:
a. Create steptypes.json in the cartridge
b. Create a custom script
c. Create job that uses this custom script
3. Test the web service in Mocked mode.
4. Create a pull request in the sfra_demo repo
5. We will review and accept your PR.