In this article, we will understand what is a REST API, what are HTTP request methods? What crud operations we can perform from those HTTP methods and lastly HTTP response codes and how to validate a REST API response through Scriptworks API testing.
What is a REST API?
An Application Programming Interface or API is a way for two computers to talk to each other using that Interface. Still, instead of clicking buttons and filling out forms, you write code to request data from a server explicitly.
Most APIs in the world are restful, which means they follow a set of rules or constraints known as REpresentational State Transfer (REST), which has been the de facto standard for API development since the early 2000s.
A restful API organizes data entities or resources into many unique URLs, technically not URLs but URIs or Uniform Resource Identifiers that differentiate different data resources on a server.
A client can receive data about a resource by making a request to that endpoint over HTTP. The request message has a particular format, most importantly, and the start line contains the URI that you wish to access, preceded by an HTTP verb or request method that signals your intent with the resource.
A GET request means you just want to read the data, while a POST implies that you want to create a new resource, PATCH is for updates, and DELETE is for removing data along with a few other methods.
Status Codes in the response at 200 level mean that things went well at the 400 level it means something was wrong with your request, and at the 500 level, it means that the server failed to process the request. After the status code; we then have the response headers which contain information about the server in turn followed by the response body which includes the data payload and is usually formatted in JSON for REST APIs.
An essential part of this architecture is that it is stateless, which means that the two parties don’t need to store any information about each other. Every request-response cycle is independent of all other communication, leading to well-behaved web applications that are predictable and reliable.
How to Look for REST Block in Scriptworks?
1) Open the project where you want to add a REST Block. And then click on the Block symbol present in the left side panel.
2) Click on the Search button on the top and place your cursor inside the Search Box.
3) Write REST inside the search box and Hit return.
And Here you go, you can see the REST Call block in Scriptworks.