API testing – How to make API request

API testing

The article today will share with you about How to make API request. When working with APIs, we only work with 2 main types of APIs: GET and POST.

– GET: Ask the server to return resources: Imagine the scene on fb, swiping new feeds.

– POST: Ask the server to create a new resource. For example, register for a ride at GrabBike.

And a request consists of 4 components:

1. URL

2. Method

3. Headers

4. Body

When entering the real project, where do you get the above information, from the developer. To test the API, you must have API documents. This depends on the company, there will be its own standards and samples, but in general, the following information must be provided: API name, purpose of use, Method, URL, params, Sample Request, Sample Response.

The article today will share with you about How to make API request. Let check it out

Create GET request

I would like to use the sample API provided by Postman.

1. URL: https://echo.getpostman.com/get (Update: https://postman-echo.com)

2. Method: GET

3. Headers: No need to fill in anything

4. Body: The GET method does not have a body, you must enter parameters in the Params

Note: All Params passed must be correct, do not leave a space or a line break.

After filling in all the information, press SEND to send the request and wait for the response to return.

The returned information will have several points of interest:

1. Return data format: usually json and should be in Pretty mode for easy viewing.

2. Data Content: This is the part you have to check.

– You compare with the Sample Response in the API docs to see if the return structure is correct or not.

– Value of each key is correct, compare with the content in the DB. (Without DB, you can’t do API testing, of course when you do API auto test, you can’t compare with DB).

3. API status (status) and return time:

Please note, the API run time with Postman is always shorter than the test time on the Mobile interface for many reasons: the internet connection at the computer is more stable than Wifi, and after receiving the response, the Mobile has to run the code to initiate the transaction. area to display.

Create POST request

Similar to the above, just enter the parameters in the body.

And so is the response part

Thank you for reading.

To see more articles about API testing , please go this link

Leave a Reply

Your email address will not be published. Required fields are marked *

API testing

Test runner – API testing

Test runner – According to the previous post, you already know how to create simple tests for each API, but a project has too many APIs and too many different tasks, each task is a collection of several APIs how must be solved. Along with that is the management method that you think is applicable […]

API testing

How to test API

After reading “test API with Postman” series, you should be able to grasp the basic knowledge of the API and the functions Postman provides. But how to arrange tests and write Testcases for API still seems not very clear, so today I will write a post about how to test API properly. Reminder of knowledge […]

API testing

API testing – API documentation

Postman, in addition to providing an API testing tool, also helps us to make API documentation extremely professional and easy. This API document can be shared by both the team and the client. Usually, the API is usually written by Dev on google sheets, but at a certain stage of development, the dev will be […]