Drupal/C4/RESTful-API-Implementation/English
|
|
Slide 1:
RESTful API Implementation |
Welcome to the spoken tutorial on RESTful API Implementation. |
Slide 2:Learning Objectives
|
In this tutorial, we will
|
Slide 3:
System requirement To record this tutorial, I am using
|
To record this tutorial, I am using
You can use any web browser as per your choice. |
Slide 4:
Pre-requisites
|
To practise this tutorial, you should have basic knowledge of Drupal.
|
Slide 5:
What is RESTful API
|
What is RESTful API?
|
Slide 5: (cont.) | For example:
|
image
|
RESTful API is a general purpose API.
can exchange data with your server. |
Show text RESTful API implementation process
|
Let us learn the RESTful API implementation process step by step.
|
Show text Step No. 1
|
Step No. 1
|
Click Extend tab | To do so, go to the Extend tab. |
Scroll down to WEB SERVICES | Scroll down and go to the WEB SERVICES section. |
Put a check mark on HAL, HTTP Basic Authentication, RESTful Web Services
and Serialization |
Put a check mark on the following modules:
HAL, HTTP Basic Authentication, RESTful Web Services and Serialization. |
Click Install button | Then click on the Install button at the bottom, to enable them. |
Show text REST UI
|
We will also need to install the REST UI module manually.
|
Show text Step No. 2
|
Step No. 2
|
Point to REST resources
|
The REST resources page appears now.
|
Scroll down
|
Scroll down.
|
Click Save configuration | Click on the Save configuration button at the bottom to save it.
|
Show text Step No. 3 | Step No. 3
|
Slide 6
|
In general, there are three kind of users that can use RESTful API.
1. anonymous user 2. authenticated user and 3. authenticated users with permission to modify content
|
Go to People tab | To do so, go to People tab. |
Click Permissions tab | Click on the Permissions tab. |
Scroll down
|
Scroll down and for AUTHENTICATED USER, put a checkmark on
Click on the Save permissions button at the bottom. |
I have enabled the authenticated users to create, edit and delete their own content.
| |
Show text Step No. 4
|
Step No. 4
|
Show text Step No. 5
|
Step No. 5
|
Click Structure → Views | To create a new view, go to Structure and Views. |
Click Add new view
Type Events_view |
Click Add view and let’s name it as Events underscore view. |
Change type as Events | Change the content of type from All to Events. |
Under REST EXPORT SETTINGS, check Provide a REST export | Under REST EXPORT SETTINGS, check Provide a REST export. |
Type REST export path as events | We will type the REST export path as events. |
Click Save and edit | Click Save and edit button at the bottom. |
Go to FORMAT → Show → Entity | Now we will set up the display of our events.
|
Choose Fields
|
In the REST export dialog box that appears, choose Fields option.
|
Click Apply | In the Row style options dialog box, keep the settings as it is.
|
Click Add | Now we can add all the fields of our Events content type.
|
In the Search box, type body | In the Search box, type body. |
Choose Body, click Add and configure fields | Choose Body from the list, then click on the Add and configure fields button. |
Click Apply | Click on the Apply button. |
Click Add | Again click on the Add button to add another field. |
Type id and choose ID | Search for id and choose ID from the list. |
Click Add and configure fields
|
Click on the Add and configure fields button.
|
Point to the path /events
|
Under PATH SETTINGS, we can see the path of our events view.
|
Show text Step No. 6
|
Step No. 6
|
Select REST export | Select REST export option.
|
Click Entity | Under FORMAT section, click on the Entity. |
Choose Fields, click Apply | Choose Fields option and click on the Apply button. |
Put check mark to all the fields
|
Check all the fields that we want in our content type.
|
Point to FIELDS | Here you can see that our required fields are added now. |
Click No path is set | Under PATH SETTINGS, we will set the path by clicking on No path is set. |
In Path field, type events/%
|
In the Path field, type events slash percentage sign.
|
Click Apply | Click on the Apply button at the bottom. |
Click ADVANCED | Now, in the right hand side, click on the ADVANCED option. |
Under CONTEXTUAL FILTERS, click Add | Under CONTEXTUAL FILTERS, click on the Add button. |
Type id in the search box
Choose ID |
We will add an ID for the contextual filter to refer our node.
|
Click Apply | Click on the Apply button. |
Click Apply | Keep the other settings as it is.
|
Click Save | Click on the Save button to save this configuration.
|
Later in the series, we will learn how to check our RESTful API using a REST Client.
| |
Slide 7:
Summary
|
Let us summarize.
|
Slide 8:
Assignment
|
As an assignment
|
Slide 9:
Acknowledgement
|
The video at the following link summarises the Spoken Tutorial project.
|
Slide 10:
Spoken Tutorial Workshops
|
The Spoken Tutorial Project Team conducts workshops and gives certificates to those who pass online tests.
|
Slide 11:
Acknowledgement
|
Spoken Tutorial Project is funded by
Government of India. |
This tutorial is contributed by Vishal Jindal.
|