# Setup Postman

Postman is a widely used software application that simplifies and streamlines the process of developing, testing, and documenting APIs (Application Programming Interfaces). It provides a user-friendly interface that allows developers to send requests to APIs and receive responses, facilitating the testing and debugging of APIs. It supports various HTTP methods such as GET, POST, PUT, DELETE, and others, enabling users to simulate different types of API requests.

#### Creating a new Postman workspace <a href="#creating-a-new-postman-workspace" id="creating-a-new-postman-workspace"></a>

Create a new workspace by clicking on the `Workspaces` button. Next click on `Create Workspace`

Give your new project a meaningful name and click on `Create Workspace`

Now you will see a sidebar with a button named `Collections`. This is where your API queries are stored. Click on `Create Collection` and create a new collection named `AthleteRequests`.

Now you should see the `AthleteRequests` collection.

Right click on `AthleteRequests` and click on `Add request`.

You will now see the following mask. First you see a dropdown in the upper left area that is set to `GET` by default. Here you can specify the kind of your HTTP requests. There are usually four types of requests used in REST APIs, however there are some more which we won't need in this course.

* ***GET***: With this type of requests you fetch data from a REST API.
* ***POST***: With this type of request you send new data that should be inserted into the database.
* ***PUT***: With this type of requests you update existing data via a REST API.
* ***DELETE***: With this type of request you delete existing data.

Remeber that these types of HTTP requests are soft conventions. We could also programm a REST API that updates and deletes records via POST requests, but it is good practice to follow this convention.

Now clik on the blue `Send` button. You will get a JSON object from the API. This is exactly the data that is stored in our database. The REST API loads this data, transformes it to a JSOn string and sends it to the client.

Now lets add new data to the database. Switch the HTTP request type from GET to POST. Now click on the `Body` tab and insert a JSON object like the one shown in the image. Click on `Send`. If you now check your database you should see that a new record was created.

The REST API will send you the following object back. It tells you that the record was created successfully.

Now lets update an existing record. For that change the HTTP request type to PUT and change the URL to `http://localhost/1`. The suffix `/1` indicates that we want to update the record with the ID 1. Click on `Send` and inspect the database afterwards.

Finally lets delete a record in the database. Change the type of the HTTP request to DELETE and set the URL to `http://localhost/1`. Click on `Send` and have a look at the database afterwards. The record with the ID 1 should now be gone. Try to send another DELETE request and have a look what happens.

### &#x20;<a href="#chapter-1-creating-teh-rest-api" id="chapter-1-creating-teh-rest-api"></a>
