12/5/2023 0 Comments Show postman consoleThe responseCode contains the response status object, so we use it to validate that the response is a 200 OK. In the login request, go to the tests tab, type the following code and send the request. Using tests, we can create different types of validation for our response. This is where tests come into play, let’s find out what they are!Īs we develop our application we need to make sure that we’re getting the proper result from the API before moving forward. The second method is to set this via code executed after the request is done. The first is to copy the token and paste it as a value for the token variable (this is what we’re trying to avoid). But how are we going to use our token now? We can use our variables inside the URL, parameters, tests, etc. Now we can update our login endpoint to use our new environment, but first we need to select our environment from the top right selection box. token: Token for future authentication.domain: current active subdomain company1, company2, etc.We need at least three variables for now: The global variables are available everywhere, separately from the selected environment. Postman has different scopes for variables: An environment is an execution context: we may have a local environment, testing, staging, etc. This nice feature alleviates the pain of copy/paste and groups our variables in one place. The four tabs are self explanatory, except for Tests which contains the tests result if we have any (more about this later). The bottom section contains all the details about the response ( status, time and size). Tests: JS code to validate the response payload.Pre-request Script: JS code to be executed before performing the request.Body: Request body for request types like Post, PUT, etc.Headers: Any header that should be sent with the request.Authorization: Specifies how to authorize the request. When ready, we can click the send button to initiate the request. If the request has some params we can specify them by clicking the Params button, which will open a table for entering them. The top bar contains the request method (in this case GET), and right next to it we specify the endpoint to make the request to. The first step to discovering Postman is making a simple API request and seeing the response.įrom the screenshot above we can see that the view incorporates different elements.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |