Home java Rest API

Rest API

Author

Date

Category

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):

  1. Getting data from the server (usually in JSON, or XML format)
  2. Adding new data to the server
  3. Modification of existing data on the server
  4. 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:

  1. Getting GET
  2. Adding – Post
  3. Modification – PUT
  4. 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:

http://sparkjava.com/

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions