API testing is a crucial step to ensure that web systems and applications function smoothly.
It involves sending different types of requests to specific API endpoints, such as GET, POST, PUT, or DELETE, to verify the server’s response and data accuracy.
The core of every API test is the step:
When I send a METHOD request to 'endpoint'
This step definition is used to send an HTTP request (GET, POST, PUT, DELETE, etc.) to a given API endpoint. It’s the action step that actually makes the call using the data, headers, and base URL you’ve set in previous steps.
Tells the test to make an HTTP request using the chosen method (GET, POST, PUT, DELETE…) to the specified path.
Example #1: When I send a GET request to "/users"
Example #2: When I send a POST request to "/posts"
Example #3: When I send a PUT request to "/users/1"
Example #4: When I send a DELETE request to "/posts/1"
Real Testing Context
We’ll use the GET method to test the /node/blog endpoint in Drupal CMS, ensuring it responds successfully with a status code of 200.
Feature: API Functional Testing for Drupal CMS Blog Endpoint
This feature demonstrates how to test the API endpoint for blog content.
It focuses on sending a GET request to the blog node and checking the response status.
Background:
Given the API base URL is "http://localhost/test/drupalCMS/web/api/v1"
Scenario: Check the blog node API response
Given I am on "/api/v1"
When I send a GET request to "/node/blog"
Given I am on "/api/v1/node/blog"
Then the API response code should be 200And now, we’ll use the GET method to test the /node/new endpoint in Drupal CMS, which will produce an error since the endpoint does not exist or respond correctly.
Feature: API Functional Testing for Drupal CMS news Endpoint
This feature demonstrates how to test the API endpoint for news content.
It focuses on sending a GET request to the blog node and checking the response status.
Background:
Given the API base URL is "http://localhost/test/drupalCMS/web/api/v1"
Scenario: Check the news node API response
Given I am on "/api/v1"
When I send a GET request to "/node/new"
Given I am on "/api/v1/node/new"
Then the API response code should be 200Note: In this feature, the step 'Given I am on' is included solely for demonstration purposes, to display the results on the screen. It can be omitted in real automated tests, as it is not required for the API verification itself.
In this video, we’ll show how to quickly test API endpoints in Drupal CMS using simple GET requests.
Display the results in the form of a report
You can see that all steps have been completed successfully

Display the results in the form of a report.
You can see that some steps have failed, and the test did not complete successfully.

Automated testing not only saves time but also prevents human errors, helping catch issues before they ever reach the end user.
And while it’s a serious process, testing can sometimes feel like a playful challenge with code: you send a request, wait for the response, and either smile when it works… or laugh when it fails.

Learn more about Step Definitions in Webship-js
Visit the documentation site:- https://webship.co/docs