</>

Technology

Rest Assured

Difficulty

Beginner

Interview Question

What are the HTTP methods used in REST API testing?

Answer

HTTP Methods in REST API Testing

REST APIs use the following HTTP methods:

MethodPurposeIdempotent
GETRetrieve a resourceYes
POSTCreate a new resourceNo
PUTUpdate/replace a resource completelyYes
PATCHPartially update a resourceNo
DELETEDelete a resourceYes
HEADSame as GET but without response bodyYes
OPTIONSReturns supported HTTP methods for the URLYes

Testing Priority

  • P1 (Critical): GET, POST, DELETE — core CRUD operations
  • P2 (High): PUT — full update
  • P3 (Medium): PATCH — partial update

Key Distinctions

PUT vs POST

  • Use PUT for UPDATE operations
  • Use POST for CREATE operations
  • PUT is idempotent (same result no matter how many times called)
  • POST is NOT idempotent (each call creates a new resource)
CODE
GET    /users          → Get all users
POST   /users          → Create a new user
GET    /users/{id}     → Get user by ID
PUT    /users/{id}     → Update user by ID
PATCH  /users/{id}     → Partially update user
DELETE /users/{id}     → Delete user by ID

Follow AutomateQA

Related Topics