# 14.1: Testing with Postman

## Intro to Postman

1. Open Postman.
2. Make sure you have a username and password for the ElevenNote app. Use a pre-existing user that is in your local database.&#x20;
3. Make sure the **.WebApi** project is running and go to the home screen.
4. Copy the URL **localhost:XXXXX**
5. Open Postman and find your way to the Postman window:<br>

   ![](https://3258533034-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAU8YfMZK4G04fkoGGv%2F-LLlT4YXsZnlKNq80jWu%2F-LLlVk8P5oY4XoCej0ro%2Fimage.png?alt=media\&token=f5b77236-ff64-4172-93d4-e95470503bf8)
6. Paste the URL into the address bar and make sure the Http drop-down is set to **POST**
7. Add **/token** to the URL
8. In the **Body** tab, add the same keys as the last request like this:
9. Check x-www-form-urlencoded.

   ![token POST](https://3258533034-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAU8YfMZK4G04fkoGGv%2F-LAxoltoX_ihZbOYkUnI%2F-LAxongRCegFva5ex3KU%2F14.1-A.png?generation=1524676902928895\&alt=media)
10. Make sure to check **urlencoded!**
11. Click on the **Headers** tab and check **Content Type**

    ![Headers](https://3258533034-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAU8YfMZK4G04fkoGGv%2F-LAxoltoX_ihZbOYkUnI%2F-LAxonhnM2bx2CQG8dhr%2F14.1-B.png?generation=1524676903063580\&alt=media)
12. Important note: If you have altered your login to use a username instead of an email, you'll want to use that username instead:

![](https://3258533034-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAU8YfMZK4G04fkoGGv%2F-LLlhrtlxbLYhFRunHgt%2F-LLliBwUERxATd8R6gC8%2Fimage.png?alt=media\&token=4cb634a9-31c3-4470-99cc-b097a975df9b)

13\. Press **Send**

14\. You should get a response with a token if you log in with the proper username/email and password.

![Token](https://3258533034-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAU8YfMZK4G04fkoGGv%2F-LAxoltoX_ihZbOYkUnI%2F-LAxonj5MG87HVTGDs7s%2F14.1-C.png?generation=1524676903050304\&alt=media)

15\. Troubleshooting common issues:\
-You didn't delete the IdentityModels after pasting the Async method in the .Data layer.\
-You didn't copy and paste the connectionStrings in the MVC project.&#x20;

16\. Save this Postman request, we will come back to it

## Notes:

* Remember Statelessness? The server we just pinged sent back a token. Be sure to talk about this in class.
* It will quickly forget us for each subsequent request
* We have to provide a token for all other authenticated requests
* We'll use this later in part 15

[Next,](https://eleven-fifty-academy.gitbook.io/dotnet-201-elevennote/elevennote-api-parts-13-19/part-15-api-controller/15.0-apicontroller) we'll add a `NoteController` to the WebAPI project.
