Video: Introduction to the B2C Service REST API

You can use the Oracle B2C Service Connect Representational State Transfer (REST) API to access the resources present in your B2C Service site using HTTP.

Let us construct an URL that targets a REST endpoint and then use a browser to find out what is there at the endpoint.

In the browser, type your site interface name, followed by the launch URL as follows:

https://your_site_interface/services/rest/connect/ 

where https://your_site_interface is your site interface name and /services/rest/connect/ is the launch URL. The text entered so far in the browser is the path to REST resources.

You need to add the version number to the path, which will be as follows:

 https://your_site_interface/services/rest/connect/v1.3

or

 https://your_site_interface/services/rest/connect/latest 

to get the latest version available.

Add the resource collection to the URL, which will be as follows:

https://your_site_interface/services/rest/connect/latest/accounts 

where accounts is the resource collection name. In general, REST API follows most of the conventions used in Connect Common Object Model. be plural and start with a lower case letter, etc.

To execute the query by navigating to the URL endpoint, you need to authenticate because you are using a secured connection (https). On executing the query, you will get the list of all accounts of your site. However, if you add a specific instance to the URL, you will get all the details about the particular object. For example, if you want details about a specific instance, which has the object number 3, you need to query as follows:

https://your_site_interface/services/rest/connect/latest/accounts/3

and you will get detailed information about the specific instance in JSON format. When you execute this call in the code, you get the values directly you need for the application by parsing the JSON.

Alternatively, you can do a GET query which is similar to a WHERE clause in SQL.

Example:

https://your_site_interface/services/rest/connect/latest/accounts?q=name.last='Griego' 

In the above URL, there is a query string (?q=name.last='Griego') which queries for last name 'Griego'. You will get the basic information on all 'Griego' present in your site.

You can do all the basic manipulations on an object using the B2C Service REST API. When you work with code, you can set the verb for the action that you want to execute other than GET, such as DELETE verb to delete an object, PATCH to update an object, or POST to create a new object or run an analytics report.