SlideShare una empresa de Scribd logo
1 de 28
Testing REST API using POSTMAN
• Postman is a powerful HTTP client for testing
web services. Created by Abhinav Asthana, a
programmer and designer based in Bangalore,
India, Postman makes it easy to test, develop
and document APIs by allowing users to
quickly put together both simple and complex
HTTP requests.
• Postman is available as a native app for Mac,
Windows, and Linux operating systems.
Installing the Postman app
• To install Postman, go to the
https://www.getpostman.com/apps
• Click Download for Mac / Windows / Linux depending
on your platform.
• macOS installation
• Once you’ve downloaded app, you can drag the file to
the “Applications” folder. Double click on Postman to
open the application.
• Windows installation
• Download the setup file
• Run the installer
Navigating Postman
Postman provides a multi-window and multi-tab interface for you to work on APIs.
This interface design gives you as much space as possible for your APIs.
Requests
In Workspaces, you can create any kind of HTTP request. The four parts of an HTTP
request are the URL, method, headers, and the body.
Responses
The Postman response viewer helps to ensure the correctness of API responses. An API
response consists of the body, headers, and the status code.
How does this work?
1. Enter your request details (URL: postman-echo.com/get) in Postman, and hit the Send button.
2. The request is received by the API server (postman-echo.com), and it returns a response.
3. The response is received by Postman, and the response is visualized in the interface.
CONSIDERATIONS OF TESTING
WEB SERVICE
A well-constructed API test suite answers questions such as:
• Does the service respond quickly enough for the intended
users?
• Will the server respond with the correct values?(Positive
Testing)
• How will the service handle exceptions and illegal
values?(Negative Testing)
• Is the service stable under expected and unexpected user
loads?(JMETER,LoadRunner)
Example of testing IPA of newbook
• API documentation for newbook:
http://newbookalliance.github.io/API/
• Base URL: https://stage-api.newbookmodels.com
Policies for all calls
• Clients should add following headers to all requests:
X-Newbook-Client: '<client>'
X-Newbook-Version: '<version>'
• API supports content negotiation
Via Accept header: Accept: application/json
• Authorization
API uses token-based authorization via Authorization header:
authorization: '<token>‘
• API Versioning
API uses url-path versioning. That means, you have to add
version prefix (e.g. /api/v1/) to each API url.
GET list of cities [GET /cities/]
GET with parameters
• A Get request can pass parameters to the server using "Query String Parameters".
• For example, in the following request,
https://stage-api.newbookmodels.com/api/v1/cities/?name=Miami
the parameter “name" has the value “Miami".
Test scripts
• With Postman you can write and run tests for each request using the JavaScript
language.
• A Postman test is essentially JavaScript code executed after the request is sent, allowing
access to the pm.response object.
Test results
• Postman runs tests every time you run a request.
• Results are displayed in a Tests tab under the response viewer. The tab header shows
how many tests passed, and the test results are listed here. If the test evaluates to true,
the test passed.
Signin [POST /auth/signin/]
• The HTTP POST request method is meant to transfer data to a server (and elicit a
response). What data is returned depends on the implementation of the server.
• To send POST request we need:
URL: https://stage-api.newbookmodels.com/api/v1/auth/signin/
Body: example of request body provided in documentation
{
"email": "a@a.aa",
"password": "qwer1234"
}
POST request structure
1. Choose POST method
2. URL is https://stage-api.newbookmodels.com/api/v1/auth/signin/
3. Go to “Body” tab to configure body
4 and 5 configure content-type.
6. Body in json format
Response
• The response returns us "token" (unique key) for clients account.
• In all clients requests(Permissions: IsClient), we have to assign token to the header.
Get self data [GET /client/self/]
• URL: https://stage-api.newbookmodels.com/api/v1/client/self/
• For authorization will use token generated from Signin request.
Request structure
• URL: https://stage-api.newbookmodels.com/api/v1/client/self/
• For authorization will use token generated from Signin request.
• Response return information about client account
Update self user data
[PATCH /client/self/]
• URL: https://stage-api.newbookmodels.com/api/v1/client/self/
• For authorization will use token generated from Signin request.
Request structure
• URL: https://stage-api.newbookmodels.com/api/v1/client/self/
• For authorization will use token generated from Signin request.
Response
Variables
• Variables allow you to reuse values in multiple places so you can keep your code DRY
(Don’t Repeat Yourself).
• Also, if you want to change the value, you can change the variable once with the
impact cascading through the rest of your code.
• Variables can be used in the following form in the Postman user interface -
{{variableName}} .
• The string {{variableName}} will be replaced with its corresponding value when
Postman resolves the variable.
• For example, for an environment variable url with the value http://localhost , you will
have to use {{url}} in the request URL field.
Add variables
Add variables
• In the table we providing variable name and value.
• After that click save and close the window.
Use variables
• Variables inside the Postman UI are enclosed inside curly braces.
Links for more information
• https://www.getpostman.com/docs/v6/
• https://docs.postman-echo.com/
TYPES OF HTTP REQUESTS
• GET – Retrieves the data from a specified source
• POST- Sends new data to a specified source
• PATCH- Updates info for a specified source
• DELETE- Removes data from a specified source
HTTP STATUS CODE
• 1XX- Codes between 100-199 mean that the server is
working on the request. Not so common
• 2XX- Codes between 200-299 mean that the request was
successful.
• 3XX- Codes between 300-399 mean that the request was
not performed.
• 4XX- Codes between 400-499 mean that the request is
incomplete and may need more info
• 5XX- Codes between 500-599 mean that the server
encountered an error.

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Api testing bible using postman
Api testing bible using postmanApi testing bible using postman
Api testing bible using postman
 
B4USolution_API-Testing
B4USolution_API-TestingB4USolution_API-Testing
B4USolution_API-Testing
 
Belajar Postman test runner
Belajar Postman test runnerBelajar Postman test runner
Belajar Postman test runner
 
Api testing
Api testingApi testing
Api testing
 
How to Automate API Testing
How to Automate API TestingHow to Automate API Testing
How to Automate API Testing
 
Test Design and Automation for REST API
Test Design and Automation for REST APITest Design and Automation for REST API
Test Design and Automation for REST API
 
Api Testing
Api TestingApi Testing
Api Testing
 
Api testing
Api testingApi testing
Api testing
 
POSTMAN.pptx
POSTMAN.pptxPOSTMAN.pptx
POSTMAN.pptx
 
Api Testing
Api TestingApi Testing
Api Testing
 
API Testing
API TestingAPI Testing
API Testing
 
Postman. From simple API test to end to end scenario
Postman. From simple API test to end to end scenarioPostman. From simple API test to end to end scenario
Postman. From simple API test to end to end scenario
 
Automation testing
Automation testingAutomation testing
Automation testing
 
API Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj RollisonAPI Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj Rollison
 
API Testing. Streamline your testing process.
API Testing. Streamline your testing process.API Testing. Streamline your testing process.
API Testing. Streamline your testing process.
 
REST API and CRUD
REST API and CRUDREST API and CRUD
REST API and CRUD
 
Rest assured
Rest assuredRest assured
Rest assured
 
REST API Design & Development
REST API Design & DevelopmentREST API Design & Development
REST API Design & Development
 
Postman Collection Format v2.0 (pre-draft)
Postman Collection Format v2.0 (pre-draft)Postman Collection Format v2.0 (pre-draft)
Postman Collection Format v2.0 (pre-draft)
 
API Testing Using REST Assured with TestNG
API Testing Using REST Assured with TestNGAPI Testing Using REST Assured with TestNG
API Testing Using REST Assured with TestNG
 

Similar a Postman.ppt

REST API 20.2 - Appworks Gateway Integration.pptx
REST API 20.2 - Appworks Gateway Integration.pptxREST API 20.2 - Appworks Gateway Integration.pptx
REST API 20.2 - Appworks Gateway Integration.pptx
Jason452803
 
REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API Recommendations
Jeelani Shaik
 
Load Impact
Load Impact Load Impact
Load Impact
z-999
 

Similar a Postman.ppt (20)

API_Testing_with_Postman
API_Testing_with_PostmanAPI_Testing_with_Postman
API_Testing_with_Postman
 
Rest WebAPI with OData
Rest WebAPI with ODataRest WebAPI with OData
Rest WebAPI with OData
 
(ATS6-PLAT04) Query service
(ATS6-PLAT04) Query service (ATS6-PLAT04) Query service
(ATS6-PLAT04) Query service
 
SCWCD : The web client model : CHAP : 1
SCWCD  : The web client model : CHAP : 1SCWCD  : The web client model : CHAP : 1
SCWCD : The web client model : CHAP : 1
 
SCWCD : The web client model
SCWCD : The web client modelSCWCD : The web client model
SCWCD : The web client model
 
How to call REST API without knowing any programming languages
How to call REST API without knowing any programming languages How to call REST API without knowing any programming languages
How to call REST API without knowing any programming languages
 
40+ tips to use Postman more efficiently
40+ tips to use Postman more efficiently40+ tips to use Postman more efficiently
40+ tips to use Postman more efficiently
 
REST API 20.2 - Appworks Gateway Integration.pptx
REST API 20.2 - Appworks Gateway Integration.pptxREST API 20.2 - Appworks Gateway Integration.pptx
REST API 20.2 - Appworks Gateway Integration.pptx
 
Spring MVC to iOS and the REST
Spring MVC to iOS and the RESTSpring MVC to iOS and the REST
Spring MVC to iOS and the REST
 
Api wiki · git hub
Api wiki · git hubApi wiki · git hub
Api wiki · git hub
 
REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API Recommendations
 
Writing Acceptance Tests Using Fitnesse
Writing Acceptance Tests Using FitnesseWriting Acceptance Tests Using Fitnesse
Writing Acceptance Tests Using Fitnesse
 
Webservice Testing
Webservice TestingWebservice Testing
Webservice Testing
 
REST API Basics
REST API BasicsREST API Basics
REST API Basics
 
Build and Manage Your APIs with Amazon API Gateway
Build and Manage Your APIs with Amazon API GatewayBuild and Manage Your APIs with Amazon API Gateway
Build and Manage Your APIs with Amazon API Gateway
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP Services
 
Load Impact
Load Impact Load Impact
Load Impact
 
AJAX.pptx
AJAX.pptxAJAX.pptx
AJAX.pptx
 
AWS API Gateway
AWS API GatewayAWS API Gateway
AWS API Gateway
 
Migrate your Existing Express Apps to AWS Lambda and Amazon API Gateway
Migrate your Existing Express Apps to AWS Lambda and Amazon API GatewayMigrate your Existing Express Apps to AWS Lambda and Amazon API Gateway
Migrate your Existing Express Apps to AWS Lambda and Amazon API Gateway
 

Último

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 

Último (20)

WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 

Postman.ppt

  • 1. Testing REST API using POSTMAN • Postman is a powerful HTTP client for testing web services. Created by Abhinav Asthana, a programmer and designer based in Bangalore, India, Postman makes it easy to test, develop and document APIs by allowing users to quickly put together both simple and complex HTTP requests. • Postman is available as a native app for Mac, Windows, and Linux operating systems.
  • 2. Installing the Postman app • To install Postman, go to the https://www.getpostman.com/apps • Click Download for Mac / Windows / Linux depending on your platform. • macOS installation • Once you’ve downloaded app, you can drag the file to the “Applications” folder. Double click on Postman to open the application. • Windows installation • Download the setup file • Run the installer
  • 3. Navigating Postman Postman provides a multi-window and multi-tab interface for you to work on APIs. This interface design gives you as much space as possible for your APIs.
  • 4. Requests In Workspaces, you can create any kind of HTTP request. The four parts of an HTTP request are the URL, method, headers, and the body.
  • 5. Responses The Postman response viewer helps to ensure the correctness of API responses. An API response consists of the body, headers, and the status code.
  • 6. How does this work? 1. Enter your request details (URL: postman-echo.com/get) in Postman, and hit the Send button. 2. The request is received by the API server (postman-echo.com), and it returns a response. 3. The response is received by Postman, and the response is visualized in the interface.
  • 7. CONSIDERATIONS OF TESTING WEB SERVICE A well-constructed API test suite answers questions such as: • Does the service respond quickly enough for the intended users? • Will the server respond with the correct values?(Positive Testing) • How will the service handle exceptions and illegal values?(Negative Testing) • Is the service stable under expected and unexpected user loads?(JMETER,LoadRunner)
  • 8. Example of testing IPA of newbook • API documentation for newbook: http://newbookalliance.github.io/API/ • Base URL: https://stage-api.newbookmodels.com
  • 9. Policies for all calls • Clients should add following headers to all requests: X-Newbook-Client: '<client>' X-Newbook-Version: '<version>' • API supports content negotiation Via Accept header: Accept: application/json • Authorization API uses token-based authorization via Authorization header: authorization: '<token>‘ • API Versioning API uses url-path versioning. That means, you have to add version prefix (e.g. /api/v1/) to each API url.
  • 10. GET list of cities [GET /cities/]
  • 11. GET with parameters • A Get request can pass parameters to the server using "Query String Parameters". • For example, in the following request, https://stage-api.newbookmodels.com/api/v1/cities/?name=Miami the parameter “name" has the value “Miami".
  • 12. Test scripts • With Postman you can write and run tests for each request using the JavaScript language. • A Postman test is essentially JavaScript code executed after the request is sent, allowing access to the pm.response object.
  • 13. Test results • Postman runs tests every time you run a request. • Results are displayed in a Tests tab under the response viewer. The tab header shows how many tests passed, and the test results are listed here. If the test evaluates to true, the test passed.
  • 14. Signin [POST /auth/signin/] • The HTTP POST request method is meant to transfer data to a server (and elicit a response). What data is returned depends on the implementation of the server. • To send POST request we need: URL: https://stage-api.newbookmodels.com/api/v1/auth/signin/ Body: example of request body provided in documentation { "email": "a@a.aa", "password": "qwer1234" }
  • 15. POST request structure 1. Choose POST method 2. URL is https://stage-api.newbookmodels.com/api/v1/auth/signin/ 3. Go to “Body” tab to configure body 4 and 5 configure content-type. 6. Body in json format
  • 16. Response • The response returns us "token" (unique key) for clients account. • In all clients requests(Permissions: IsClient), we have to assign token to the header.
  • 17. Get self data [GET /client/self/] • URL: https://stage-api.newbookmodels.com/api/v1/client/self/ • For authorization will use token generated from Signin request.
  • 18. Request structure • URL: https://stage-api.newbookmodels.com/api/v1/client/self/ • For authorization will use token generated from Signin request. • Response return information about client account
  • 19. Update self user data [PATCH /client/self/] • URL: https://stage-api.newbookmodels.com/api/v1/client/self/ • For authorization will use token generated from Signin request.
  • 20. Request structure • URL: https://stage-api.newbookmodels.com/api/v1/client/self/ • For authorization will use token generated from Signin request.
  • 22. Variables • Variables allow you to reuse values in multiple places so you can keep your code DRY (Don’t Repeat Yourself). • Also, if you want to change the value, you can change the variable once with the impact cascading through the rest of your code. • Variables can be used in the following form in the Postman user interface - {{variableName}} . • The string {{variableName}} will be replaced with its corresponding value when Postman resolves the variable. • For example, for an environment variable url with the value http://localhost , you will have to use {{url}} in the request URL field.
  • 24. Add variables • In the table we providing variable name and value. • After that click save and close the window.
  • 25. Use variables • Variables inside the Postman UI are enclosed inside curly braces.
  • 26. Links for more information • https://www.getpostman.com/docs/v6/ • https://docs.postman-echo.com/
  • 27. TYPES OF HTTP REQUESTS • GET – Retrieves the data from a specified source • POST- Sends new data to a specified source • PATCH- Updates info for a specified source • DELETE- Removes data from a specified source
  • 28. HTTP STATUS CODE • 1XX- Codes between 100-199 mean that the server is working on the request. Not so common • 2XX- Codes between 200-299 mean that the request was successful. • 3XX- Codes between 300-399 mean that the request was not performed. • 4XX- Codes between 400-499 mean that the request is incomplete and may need more info • 5XX- Codes between 500-599 mean that the server encountered an error.