The other day, the sake of interest threw a summary of the company, sent preliminary testing. It is said to implement the REST API to work with the contents of text files. What is the REST API, simple words? And what (preferably simple) implementation of this (for any task, not necessarily work with files) is there on C # / java? I would be grateful to any answer.
Answer 1
Reply to the same question from here: https://qna.habr.com/answer? Answer_id = 390415
API of social networks – this is quite typical examples of the implementation of the REST
API.REST (RESTful) is the general principles of the organization of interaction
Applications / Site with the server via HTTP protocol. Peculiarity
REST is that the server does not remember the user’s status between
Requests – information identifies information in each request
user (for example, token, obtained through oauth-authorization) and
All parameters required to perform operation.All interaction with the server comes down to 4 operations (4 – it
necessary and sufficient minimum, in the specific implementation of types
operations may be greater):
- Getting data from the server (usually in JSON, or XML format)
- Adding new data to the server
- Modification of existing data on the server
- Delete data on the server
Data generation operation cannot lead to a state change
Servers.For each type of operation, your HTTP request method is used:
- Getting GET
- Adding – Post
- Modification – PUT
- Delete – Delete
i.e. :
Get-query / REST / Users – Getting information about all users
Get-query / REST / Users / 125 – Receiving User Information with
ID = 125 POST request / REST / Users – adding new user
Put-query / REST / Users / 125 – Changing the user information with
ID = 125 DELETE Query / REST / USERS / 125 – Deleting a user with ID = 125
Article about REST API on Java:
https://habr.com/en/company/otus/blog/ 480564 /
There are REST frameworks for Java, for example, Spark: