Access and Test with Postman - project 1 - Notes By ShariqSP

Access and Test with Postman - errors are introduced intentionally to make you understand

Use the following Postman requests to interact with the API endpoints hosted at http://apitesting.shariqsp.com:8080/. You can use these endpoints to test CRUD operations for user management.

Click here to view the Swagger UI documentation

Getting Started with Postman

To streamline your API testing, create variables in Postman to store common values, such as the base URL or authentication tokens. This will make it easier to update your setup later without modifying every request.

  • Step 1: Go to Environment Variables in Postman and create an environment for your API. Set up a variable called base_url with the value http://apitesting.shariqsp.com:8080/.
  • Step 2: If needed, create variables for credentials (e.g., username, password) or the authorization token, which you will use in the headers after logging in.

1. Register User

Endpoint: POST {{base_url}}/api/users/register

Description: Use this endpoint to create a new user account by sending the necessary user details in the request body.

Body (JSON):

                {
                    "username": "johndoe",
                    "email": "john@example.com",
                    "mobile": "1234567890",
                    "password": "password123"
                }
                

Note: Set the request type to POST in Postman and use the Body tab with JSON format.

2. Login User

Endpoint: POST {{base_url}}/api/users/login

Description: This endpoint authenticates the user and, if successful, may return a token that can be used for authorized requests.

Body (JSON):

                {
                    "username": "johndoe",
                    "password": "password123"
                }
                

Note: After logging in, if a token is returned, store it in a Postman variable, e.g., auth_token. Then, include it in the headers of subsequent requests as Authorization: Bearer {{auth_token}}.

3. Get All Users

Endpoint: GET {{base_url}}/api/users/all

Description: Fetches a list of all users in the system. Include the authorization token in the headers if required.

Note: Set the request type to GET in Postman and add the authorization header if needed.

4. Update User

Endpoint: PUT {{base_url}}/api/users/update

Description: Updates a user's information, identified by their id. Ensure the updated details are sent in the request body.

Body (JSON):

                {
                    "id": 1,
                    "username": "johndoe",
                    "email": "john_updated@example.com",
                    "mobile": "9876543210",
                    "password": "newpassword"
                }
                

Note: Set the request type to PUT and include the Authorization header if the endpoint requires authentication.

5. Delete User

Endpoint: DELETE {{base_url}}/api/users/delete/{id}

Description: Deletes a user based on their unique id. Replace {id} in the URL path with the specific user's ID.

Note: Set the request type to DELETE and use the Authorization header if required.