Post Request | Bondar Academy
Course: Playwright API Testing with TypeScript
Module: API Testing Basics
Instructor: Artem Bondar
Lesson Summary
In this lesson, we learned how to make a POST request using Playwright . Here are the key points covered: Overview of POST Request Previously, we used Postman to create an article by providing: The API URL The request body for the article An authorization header obtained from the browser's network tab Obtaining the Authorization Token To automate API calls without a browser, we need to retrieve the authorization token differently: Inspect user details and log out. Sign in again to capture the login request in the network tab. Extract the token from the response payload. The token is saved in local storage as a JWT token and is used for all subsequent API requests. Simulating the Request in Postman We created a new request in Postman to obtain the token: POST {API_URL} Body: {request_body} Upon sending the request, we received a unique token each time. Implementing in Playwright To recreate this in Playwright: Create a new test for creating an article. Use the request fixture to make a POST request. Pass the API URL and the request body as an object. Extract the token from the response JSON. Summary To make a POST request in Playwright: Call the POST method with the API URL and an object containing the request body. Extract the JSON response and retrieve the auth token . In the next lesson, we will use this token to create an article with another POST request.