0% found this document useful (0 votes)
23 views3 pages

Rest Questions

Uploaded by

mrinalkd12345
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views3 pages

Rest Questions

Uploaded by

mrinalkd12345
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

REST QUESTIONS

1. What is a REST API?


- A REST API is an interface that allows interaction with a web service using
standard HTTP methods. It adheres to REST principles, making it stateless and
using URLs to represent resources.

2. What does REST stand for, and what are its key principles?
- REST stands for Representational State Transfer. Its key principles are
statelessness, client-server architecture, cacheability, uniform interface, and
layered system.

3. What are the key HTTP methods used in REST, and what do they do?
- GET: Retrieve data.
- POST: Create new resources.
- PUT: Update or replace resources.
- DELETE: Remove resources.
- PATCH: Partially update resources.

4. What is the difference between PUT and POST in REST API?


- PUT updates or replaces a resource at a specific URL and is idempotent
(repeated requests yield the same result). POST creates a new resource and
may lead to different results on repeated requests.

5. What is statelessness in REST?


- Statelessness means that each API request from a client to a server must
contain all the information needed to understand and process the request. The
server does not store any client context between requests.
6. What is a resource in REST, and how is it represented?
- A resource is an object or entity that the API can manipulate. It is
represented by a URI (Uniform Resource Identifier) and can be returned in
formats like JSON or XML.

7. What are the typical response codes used in REST APIs, and what do they
signify?
- 200 OK: Request successful.
- 201 Created: Resource created.
- 204 No Content: Request successful, no content to return.
- 400 Bad Request: Invalid request.
- 404 Not Found: Resource not found.
- 500 Internal Server Error: Server error.

8. What is the purpose of using status codes in a REST API?


- Status codes communicate the outcome of an API request, helping clients
understand whether the request was successful, resulted in an error, or if
additional actions are required.

9. What is RESTful URI naming, and why is it important?


- RESTful URI naming involves using clear, consistent, and meaningful URIs to
identify resources. It improves readability and maintainability by following
resource-oriented naming conventions.

10. What is HATEOAS, and why is it important in REST?


- HATEOAS (Hypermedia as the Engine of Application State) allows clients to
navigate the API dynamically using links provided in responses, making the API
more self-descriptive and easier to use.
11. How do you handle errors in a REST API?
- Errors are handled by returning appropriate HTTP status codes and detailed
error messages in the response body to inform clients of the issue.

12. What is the difference between JSON and XML in REST APIs?
- JSON is lightweight, easy to parse, and more commonly used. XML is more
verbose and supports richer data structures but is less efficient.

13. How do you version a REST API?


- API versioning can be done via URI paths (e.g., /api/v1/resource), query
parameters (e.g., /api/resource?v=1), or headers (e.g., Accept:
application/vnd.myapi.v1+json).

14. What are RESTful best practices for securing APIs?


- Use authentication (e.g., OAuth), enforce HTTPS for encryption, and
implement proper access control and rate limiting.

15. What is CORS, and how does it relate to REST APIs?


- CORS (Cross-Origin Resource Sharing) is a security feature that allows or
restricts web applications from making requests to a different domain. It’s
relevant for REST APIs when accessed from web browsers.

You might also like