Automate Coronavirus COVID19 REST API POST METHOD Tutorial Part2




REST API Automation Testing Tutorial Part 2:In this tutorial we are going to focus on testing the HTTP POST method using REST ASSURED API. To know more details about the REST and REST ASSURED API and testing HTTP GET method. Please refer to this link.
1. Understanding Post Request
REST Endpoint URL : https://api.covid19api.com/auth/access_token
AUTHORIZATION: Basic Auth
Username:go-corona-admin
Password:5577YvzU4bK63a1WIQ3Z043H
Body:
{“Email”:”test1@covid19api.com”, “Subscription”:”basic”}
Response:
{ ‘result’ : ‘success’ }
Response Code:
200
Response Headers:
Server: nginx/1.14.0 (Ubuntu)
Date: Sun, 22 Mar 2020 08:07:30 GMT
Content-Type: application/json
Content-Length: 24
Connection: keep-alive
Vary: Origin

2. Design Test Cases

REST ASSURED REST API HTTP POST TESTCASES

REST ASSURED REST API HTTP POST TESTCASES

3. Pre-requisites
io.restassured
maven dependency
add the dependency in the pom.xml

4. Post Method Example

  • Validate Response Code
  • Validate Response Headers
  • Validate Response Body
  • Validate 401 unauthorized response


Java Logic

Conclusion:
Validated Response Code
Validated Response Headers
Validated Response Body
Validated 401 unauthorized response

REST ASSURED HTTP POST METHOD RESULTS

REST ASSURED HTTP POST METHOD RESULTS

Leave a Reply

Your email address will not be published. Required fields are marked *