📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

πŸ“š .NET Interview Questions

1325 questions for senior .NET engineer interviews, each with a 30-second answer, the full answer, a deep dive, the follow-ups interviewers ask next, and real-world production problems.

Phase 13 — Web APIs and HTTP

Designing and running HTTP APIs well: HTTP semantics, REST principles, API design (versioning, pagination, errors and contracts) and reliability features such as rate limiting, idempotency keys, caching and gateways, in ASP.NET Core 10.

  1. How do you make a POST endpoint safe to retry when the operation is not naturally idempotent, such as taking a payment?
    Junior Theory HTTP Fundamentals
  2. Why might an API return 404 instead of 403 when a user requests another customer's resource, and what are the trade-offs?
    Junior Theory HTTP Fundamentals
  3. What does an HTTP request and response actually look like on the wire? Walk through the start line, headers and body, explain when data belongs in the route, the query string, a header or the body, and how ASP.NET Core exposes each part to your code.

    The anatomy of an HTTP/1.1 request and response, where API data belongs (route, query, header, body) and how HttpContext, HttpRequest and HttpResponse expose it in ASP.NET Core.

    Beginner Theory HTTP Fundamentals Β· πŸ”— 3 follow-ups
  4. Which HTTP method would you use for each operation in an API? Explain GET, POST, PUT, PATCH, DELETE, OPTIONS and HEAD, which are safe and which are idempotent, which may carry a body, and why those properties matter in practice.

    The HTTP methods as an API contract: meaning of each, the safe, idempotent and cacheable properties, body rules, and how retries, caches and proxies rely on them.

    Junior Theory HTTP Fundamentals Β· πŸ”— 2 follow-ups
  5. How do you choose the right HTTP status code in an API? Explain 200 vs 201 (with Location) vs 202 vs 204, 400 vs 422, 401 vs 403, 404 vs 410, when to use 409, 412 and 429, and how 500 differs from 502, 503 and 504.

    Choosing status codes as part of the API contract: success codes, client error distinctions (400/422, 401/403, 404/410, 409, 412, 429) and server/gateway errors (500, 502, 503, 504).

    Junior Theory HTTP Fundamentals Β· πŸ”— 3 follow-ups
  6. Which HTTP headers should every API engineer know? Explain Content-Type and Accept, Authorization, Cache-Control and ETag, Location, Retry-After, traceparent, and the X-Forwarded-* family, and what goes wrong in production when each is missing or trusted blindly.

    The headers that shape an HTTP API contract: content negotiation, authentication, caching and validators, Location, Retry-After, W3C trace context and forwarded headers behind proxies.

    Intermediate Theory HTTP Fundamentals Β· πŸ”— 2 follow-ups
  7. What is the difference between PUT and PATCH? Explain full replacement vs partial update, JSON Patch (RFC 6902) vs JSON Merge Patch (RFC 7396), how you tell a missing field from an explicit null, and show how you implement PATCH in ASP.NET Core on .NET 10.

    PUT as full replacement vs PATCH as partial update, JSON Patch vs JSON Merge Patch, the missing-vs-null problem, and implementing PATCH in ASP.NET Core 10 with System.Text.Json, validation and concurrency.

    Mid-Level Coding HTTP Fundamentals Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  8. How do you design the query string of an API? Explain how to model filters, arrays and ranges, how encoding works, what the practical length limits are, and when a search should be a POST instead of a GET.

    Query string design for APIs: filter, array and range conventions, percent-encoding, URL length limits in Kestrel, IIS, proxies and browsers, binding in ASP.NET Core, and when to switch search to POST.

    Intermediate Theory HTTP Fundamentals Β· πŸ”— 2 follow-ups
  9. After a release, clients of your API start getting 405 Method Not Allowed, 415 Unsupported Media Type or a bare 400 with no body, and the browser app reports that the CORS preflight failed. How do you work out which layer is rejecting the requests, and how do you fix each case?

    Diagnosing method and content-type contract failures (405, 415, empty 400, failed CORS preflight) across clients, gateways and ASP.NET Core, with the tools and fixes for each.

    Mid-Level Debugging HTTP Fundamentals Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  10. What are HEAD and OPTIONS for in an HTTP API? Explain CORS preflight, capability discovery with the Allow header, cheap existence and size checks with HEAD, and what ASP.NET Core does for you automatically versus what you must map yourself.

    The HEAD and OPTIONS methods: semantics, CORS preflight, Allow-based capability discovery, HEAD for existence, size and freshness checks, and how ASP.NET Core routing, CORS and static files handle them.

    Mid-Level Theory HTTP Fundamentals Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  11. Code review: an orders API uses GET /orders/{id}/cancel to cancel an order, returns 200 with {"success": false, "error": "..."} on failures, sends every operation as POST, and has URLs like /api/getOrders, /api/createOrder and /api/deleteOrder. What problems do you find, ranked by severity, and how would you redesign it?

    Reviewing an RPC-style HTTP API that violates method semantics (state change on GET, POST for everything, verbs in URLs) and hides failures behind 200 responses, then redesigning it around resources, correct methods and status codes.

    Senior CodeReview HTTP Fundamentals Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  12. What is REST? Explain Fielding's architectural constraints (client-server, statelessness, cacheability, uniform interface, layered system, code on demand), what the uniform interface really requires, and what people mean in practice when they call an API "RESTful".

    REST as an architectural style: Fielding's six constraints, the four parts of the uniform interface, and the gap between academic REST and the pragmatic "RESTful" JSON-over-HTTP APIs most teams build.

    Junior Theory REST Β· πŸ”— 2 follow-ups
  13. How do you map CRUD operations onto HTTP? When should a create be a POST to a collection and when a PUT to a known URI, how do you implement an upsert with PUT, and what is the difference between a collection resource and an item resource?

    Mapping create, read, update and delete to HTTP methods and status codes: POST to a collection vs PUT to an item, upsert semantics, collection vs item resources, and the responses each should return.

    Junior Theory REST Β· πŸ”— 3 follow-ups
  14. How do you design resource URIs for a REST API? Explain nouns vs verbs, plural collection names, how deep to nest sub-resources, when to use a sub-resource vs a top-level resource with a filter, and the naming conventions (casing, ids, trailing slashes, file extensions) you would standardise on.

    URI design for REST APIs: noun-based plural collections, nesting depth and sub-resources, top-level resources with filters, identifiers, casing and other conventions worth standardising across an API.

    Intermediate Theory REST Β· πŸ”— 2 follow-ups
  15. What do safety and idempotency mean for a REST API in practice? Why do clients, gateways and resilience handlers depend on them when retrying, how do you test that an endpoint really is idempotent, and what design options do you have when an operation must be retryable but isn't naturally idempotent?

    Safety and idempotency as a retry contract: why every layer that retries depends on them, idempotency as effect on state, testing it, and the design options (PUT with client ids, conditional requests, idempotency keys, natural dedup) for retry-safe writes.

    Intermediate Theory REST Β· πŸ”— 3 follow-ups
  16. What is HATEOAS, and what are the levels of the Richardson maturity model? Walk through levels 0 to 3 with examples, explain what hypermedia buys a client, whether anyone really uses it in production, and what pragmatic stance you would take for a .NET API.

    Hypermedia as the engine of application state and the Richardson maturity model levels 0-3, with examples, the real benefits and costs of hypermedia, where it is used (HAL, JSON:API, Siren, Microsoft Graph nextLink), and a pragmatic stance for ASP.NET Core APIs.

    Mid-Level Theory REST Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  17. How do you choose between REST, gRPC, GraphQL and asynchronous messaging for an API? Compare them on contract, performance, browser and tooling support, caching, coupling and failure handling, and give examples of where each fits in a .NET system on Azure.

    Choosing an API style: REST over HTTP, gRPC, GraphQL and asynchronous messaging compared on contracts, performance, client support, caching, coupling and failure semantics, with typical placements in a .NET 10 system on Azure.

    Mid-Level Theory REST Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  18. How do you model operations that aren't simple CRUD in a REST API? Compare POST /orders/{id}/cancel, a cancellation sub-resource and PATCH on a status field for state transitions, and show how you implement a long-running operation in ASP.NET Core with 202 Accepted, a status resource, Retry-After and a final result.

    Modelling non-CRUD operations: state transitions as action endpoints, sub-resources or PATCH, and the asynchronous request-reply pattern (202 Accepted, Location/Operation-Location, status resource, Retry-After, result link) implemented in ASP.NET Core 10 with a background worker.

    Mid-Level Coding REST Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  19. You're asked to design a public REST API that external partners will integrate with for years. How do you approach the resource model, naming and consistency, versioning and evolution, errors, pagination, security, documentation and SDKs, and which published guidelines (such as Microsoft's REST API guidelines) would you base your standards on?

    Designing a long-lived partner-facing REST API: domain-driven resource model, consistent conventions, a guideline baseline (Azure / Microsoft Graph REST API guidelines, Google AIP, Zalando), evolution and versioning policy, errors, paging, security, and the documentation and SDK experience, on ASP.NET Core 10 and Azure API Management.

    Senior Architecture REST Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  20. How would you retire v1 of an API that 30 partners still call?
    Intermediate Theory API Design

🌐 Sangam's Webring

βͺ Previous 🏠 Main Next ⏩
πŸ’¬ Chat with me