Webapi Interview Questions Rest Security Versioning 2025 Interview Questions & Answers
30 questions available
Mid
Answer
REST requires:
Resource-based URI
Stateless operations
Representations (JSON/XML)
HATEOAS (optional but ideal)
RPC:
Action-based URIs (/getUser, /updateStatus)
Tight coupling with client
Harder long-term scalability
REST enforces loose coupling and evolvability.
Mid
Answer
POST ? non-idempotent
PUT ? idempotent (replace state)
PATCH ? partially idempotent depending on payload
DELETE ? idempotent (deleting twice gives same result)
Idempotency protects APIs under retries and failures.
Mid
Answer
Reasons:
Enumeration attacks
Data mining
Security leakage
Predictable IDs ease scraping
Solutions:
ULIDs
GUIDs
Snowflake IDs
Hash IDs
Mid
Answer
Authentication ? Who are you?
Authorization ? What can you access?
Delegation ? Acting on behalf of another (OAuth 2.0)
Mid
Answer
PKCE adds:
Code verifier
Code challenge
Prevents code interception attacks
Ideal for SPA and mobile apps.
Mid
Answer
Long-lived JWTs cause:
Token replay
Unrevokable access
Stolen-token persistence
Best practice:
Short expiry (5–15 min)
Refresh tokens with rotation
Server-side token store.
Mid
Answer
HATEOAS:
Hypermedia links discover resource actions
Schema-driven:
Actions inferred from API specification
HATEOAS = runtime discoverability
OpenAPI = development-time discoverability.
Mid
Answer
Because:
Centralized error format
Reduced boilerplate
Consistent logging
Unified error codes
Supports RFC 7807 Problem Details.
Mid
Answer
PUT ? complete replacement
PATCH ? delta updates (JSON Patch or Merge Patch)
PATCH is more network-efficient.
Mid
Answer
Gateway exchanges:
Client token ? internal service token
Protects internal services
Reduces token exposure
Minimizes permissions.
Mid
Answer
Pessimistic throttling:
Deny early based on pre-calculated usage.
Optimistic throttling:
Allow and evaluate limit post-execution.
Optimistic is better for distributed systems.
Mid
Answer
Timestamps:
Time-zone issues
Clock drift
Partial content mismatch
ETag:
Hash-based versioning
Exact matches
Supports optimistic concurrency.
Mid
Answer
URL versioning ? most explicit
Header versioning ? clean URLs
Query versioning ? not RESTful but simple
Accept-header versioning ? best REST practice
Mid
Answer
Enables:
JSON / XML / MsgPack / Protobuf
Versioning via Accept header
Extensible APIs without breaking clients.
Mid
Answer
409 ? resource state conflict
412 ? ETag mismatch (optimistic locking)
Mid
Answer
Stateless:
Scalable
Cacheable
Load-balanced easily
Breaks statelessness:
Server sessions
In-memory user data
Sticky sessions
Mid
Answer
Token Bucket ? burst-friendly
Leaky Bucket ? constant rate
Fixed Window ? simplest, inaccurate at edges
Sliding Window ? most accurate for production
Mid
Answer
Circuit Breakers prevent:
Cascading failures
Downstream overload
States:
Closed
Open
Half-open
Mid
Answer
Composition: Gateway merges responses from multiple services
Aggregation: Backend services aggregate internally
Composition = external merge
Aggregation = internal merge
Mid
Answer
Because detailed errors reveal:
Internal architecture
DB/table hints
Framework details
Attack vectors
Return generic messages instead.
Mid
Answer
PUT ? updates or replaces a resource at the given URI
POST action ? executes a workflow or domain action not tied to a resource identity
Action-based POSTs are ideal for:
State transitions
Commands
Non-resource operations.
Mid
Answer
HTTP/2:
Multiplexing
Binary framing
Header compression
HTTP/3:
QUIC protocol
Zero-RTT
Better performance under packet loss
Both drastically reduce API latency.
Mid
Answer
Overposting occurs when clients send fields not intended for update.
DTOs prevent it by:
Defining allowed fields
Ignoring unknown fields
Enforcing strict validation
Ensures security and data integrity.
Mid
Answer
Offset:
Simple
Slow on large tables
Causes duplicate/skip anomalies
Cursor:
Uses unique ID or timestamp
Fast
Consistent
Ideal for infinite scrolling and real-time data.
Mid
Answer
GUID/ULID benefits:
Avoid sequential key exposure
Support high concurrency
Work across distributed clusters
Globally unique
ULIDs also provide sortable IDs.
Mid
Answer
Client-side validation ? UX improvement
Server-side validation ? Security + Data integrity
Server must never trust client inputs.
Mid
Answer
Typed errors provide:
Consistent structure
Machine-readable format
Better debugging
Compliance with RFC 7807 Problem Details
Plain strings break automation and consistency.
Mid
Answer
HSTS forces HTTPS at browser level.
Prevents:
SSL stripping
MITM attacks
Protocol downgrade
Adds strong API security hardening.
Mid
Answer
Use WebSockets for:
Real-time chat
Notifications
Live dashboards
Stock price streaming
Multiplayer games
REST is request-response; WebSockets are bi-directional streaming.
Mid
Answer
JSON logs are:
Machine-readable
Easy to index
Searchable in ELK, Splunk, Azure Monitor
Support correlation IDs
Ideal for large distributed APIs.