Creating Requests
Let’s create a new request in Postman. In the request, we can have many details. And during this request creation process, you have to enter a URL and select the method. Other than you can optionally specify the number of additional information.
To create a request, follow the following steps:
Step 1: Launch the Postman.
Step 2: Click on New option from the top left corner of the Postman homepage window. Once you click on the button, a drop-down menu will open.
Step 3: Click on the Request option from the drop-down list.
Step 4: Once you select the Request option, you will be prompted to enter the request name, and you can also describe that API for future use. The description section is optional; we can leave it blank.
Here my Request name is “My API.”
Step 5: Scroll down and click on + Create Collection.
Enter the collection Name (here, ‘Collection-01’ is my collection name) and click on the right mark.
Step 6: Click on the Save button to create your request.
Once you click on the save button, a new tab will open with your given request name.
Step 7: Enter www.tutoraspire.com in the address bar and click on Send.
Once you select the Send, you will get the following response.
Setting Request URLs
For sending the request, you should have a URL that defines the API endpoint. All API operation is usually associated with an endpoint, which is a place from where these APIs can access the resources that are required to perform their task.
To access the API in Postman, you need to enter the URL, and each URL contains an endpoint.
- When you create an API, usually, the URL is the base location plus path. For example, https://tutoraspire.com/java-tutorial, where https://tutoraspire.com is the base URL and /java-tutorial, is the endpoint path.
- And if you use a third-party API, then you don’t need to supply the URL, your API provider will supply the URL you need.
Selecting Request Methods
Once you enter the URL in the URL text field, the GET method will be selected for new requests by default. There are multiple other methods available.
Some commonly used methods are:
GET: This HTTP method is used to retrieve data from an API.
POST: To send the new data to an API, we can use this method.
DELETE: This is used to remove or delete the existing data.
PATCH: This method is used to update the existing data.
PUT: This method is used to update the existing data.