Examples of requests and responses

For recive allsupercars, the request would look like this:
GET http://localhost:50043/api/supercars
Accept: application/json

or for single record with id = 1

GET http://localhost:50043/api/supercars/1
Accept: application/json

A possible response header would look like:

Status Code: 200 (OK)
Content-type: application/json

followed by thesupercarsdata requested inapplication/jsonformat.

GET http://localhost:50043/api/supercars/3/wheels/1
Accept: application/json
Create a newsupercarentity by posting the data:
POST http://localhost:50043/api/supercars
Body:
{
    "brand": "Pegeuot",
    "model": "207",
    "body": 2,
    "year": 2016
}

The server then generates anidfor that object and returns it back to the client, with a header like:

Status Code: 201 (CREATED)
Content-type: application/json
Update that supercar with an id = 14by PUT request:
PUT http://localhost:50043/api/supercars/14
Body:
{
    "brand": "Honda",
    "model": "Odyssey",
    "body": 10,
    "year": 2017
}
Partial update via PATCH request:
PATCH http://localhost:50043/api/supercars/14
Body:
{
    "model": "Civic",
    "body": 2
}

A possible response header would haveStatus Code: 200 (OK), to notify the client that the item with id = 14 has been modified.

Deleting supercar by specifying itsid:

DELETE http://localhost:50043/api/supercars/14

The response would have a header containingStatus Code: 204 (NO CONTENT), notifying the client that the item withid = 14has been deleted, and nothing in the body.

results matching ""

    No results matching ""