HTTP Methods:
Most REST_ful_ APIs tend to implement the four most common HTTP methods; GET for retrieval, PUT for updates, POST for creation and DELETE for, well, deleting resources. Our example API is no different. So, let’s modify our albums resource to reflect this:
/albums:
get:
description: Retrieve a list of albums
post:
description: Create a new album
/{isrc}:
uriParameters:
isrc:
description: The International Standard Recording Code which uniquely identifies this album
type: string
pattern: ^[a-zA-Z]{2}\-[0-9a-zA-Z]{3}\-\d{2}\-\d{5}$
get:
description: Retrieve the specified album
put:
description: Update an album
delete:
description: Delete this album
Here we’re indicating that a
GET request to /albums will retrieve a list of albums, and a POST to the same URI is used to create one. Drilling-down, a GET request to /albums/{isrc} will retrieve information about a specific album, specified using the URI parameter isrc. a PUT request is used to update the album, aDELETE request to delete it.
No hay comentarios:
Publicar un comentario