Understanding REST
REST usually uses the Hypertext Transfer Protocol (HTTP) to set up communication between the client and the server. REST APIs ensure that the server transfers information in a standard format. A REST API call generally contains the following steps -- The client sends a request to the server.
- The server authenticates the client and ensures that the client is authorized to request the information.
- The server accepts the requests and processes them.
- The server responds with a code to tell the client if the request was successful or not and sends the requested information if the request was successful.
Status Code | Response Type |
---|---|
1xx (100-199) | Informational |
2xx (200-299) | Success |
3xx (300-399) | Redirection |
4xx (400-499) | Client error |
5xx (500-599) | Server error |
HTTP Method | Usage |
---|---|
GET | Retrieve resource from a server |
POST | Create or send new resource |
PUT | Updating resource, can also be used for creating resource |
PATCH | Similar to PUT, can be used to modify resources |
DELETE | Delete resource from the server |
HEAD | Read HTTP header information |
CONNECT | To start a two-way communication with resource |
OPTIONS | Requests permitted communication options for a given URL or server |
TRACE | Used to debug the path to the target resource |
CUSTOM | Create custom methods as per your need |
Using Postdata to test your REST APIs
Postdata provides you with a minimal yet robust platform to test your REST APIs. The REST platform is the default platform you see when you open Postdata. You can enter the API endpoint and choose the HTTP method according to your needs from the dropdown menu. Once it is configured, click on the “Send” button and you will see the response returned by the server. It’s that simple. Now try it yourself, copy the below API endpoint, and create a request.Locally served APIs
If you are planning to use Postdata to test your locally served APIs, it is recommended that you install the Postdata Browser Extension. Once installed, switch the interceptor on Postdata to Browser Extension from the settings page or bottom bar to add support for localhost protocols.Adding parameters to your request
You can also parameterize your URLs by specifying parameters in the URL itself or adding parameters manually in the parameters tab. To add a parameter in the URL, append?
at the end of the URL and add a parameter in key=value
format.
Working with environment variables
Environment variables allow you to store and reuse values in your requests and scripts. You can create a new environment by clicking the environments icon on the sidebar and clicking thenew
button.
If you have more than one environment, select the environment whose variables you want to access. You can access the variables in the request section by referencing the variable in the following format<<variable_name>>
.