I trust that you found this blog post to be enjoyable. If you are interested in having my team handle your eCommerce setup and marketing for you, Contact Us Click here.

HTTP methods used in REST API

HTTP methods used in REST API

In REST (Representational State Transfer) APIs, several HTTP methods
are used to perform operations on resources. Each method corresponds to a
specific type of operation. The primary HTTP methods used in REST APIs
are

1. GET : 

  • Purpose: Retrieve data from the server. 
  • Usage: Used to request data from a specified resource.
  • Idempotent: Yes (repeated requests have the same effect as a
    single

 

2. POST :

  • Purpose: Update an existing resource or create a resource if it does not exist.
  • Usage: Used to update a specified resource with the provided
    data.
  • Idempotent: Yes (repeated requests with the same data will
    have the same effect).

 

3. PATCH :

  • Purpose: Partially update an existing resource.
  • Usage: Used to apply partial modifications to a resource.
  • Idempotent: Yes (repeated requests with the same data will
    have the same effect).

 

4. DELETE

  • Purpose: Delete a specified resource from the server.
  • Usage: Used to remove a specified resource.
  • Idempotent: Yes (repeated requests to delete a resource will have the same effect).

 

Drupal Modules to Expose your API

Mentioned below are some Drupal core and contributed modules that can
help in exposing your APIs in Drupal.

1. RESTful Web Services: 

  • Part of Drupal core, this module allows you to expose entities and custom resources as RESTful web services.
  • Supports GET, POST, PATCH, DELETE, and other HTTP methods for various entities like nodes, users, comments, etc.

 

2. HTTP Basic Authentication:

  • The HTTP basic authentication module provides an authentication plugin which allows us to control access to our API resources based on the HTTP method.

 

3. Serialization:

  • This module provides services for serialization of data (e.g., JSON, XML).

 

4. REST UI: 

  • A contributed module that provides a user interface for managing RESTful web services in Drupal.
  • Simplifies the configuration of REST resources, allows you to manage endpoints and methods through the UI, and integrates with the core REST module.
Back to blog