¿Qué aprenderá?

En este tutorial aprenderá a construir una documentación del diseño de un API usando Postman.

¿Qué construirá?

La documentación del diseño de un API.

¿Qué necesita?

En particular Ud. debe:

  1. Un equipo con la herramienta Postman instalada.

En Postman una colección es un conjunto de peticiones (u operaciones) que se realizan al API. Como decisión de diseño tendremos una colección por cada uno de los recursos del API. Para este tutorial tomaremos como referencia el recurso museos.

Diríjase a la sección Collections que se encuentra en el menú de la izquierda. Allí debe dar clic en el símbolo + o en el botón New.

Allí se redirigirá a una página la cual le permitirá elegir un nombre para la colección. Para este caso dejamos como nombre Museums.

Después de esto, haremos clic en Save en la esquina superior derecha para guardar todos nuestros cambios de la colección:

Crear un museo

A continuación documentamos las operaciones del API. Iniciamos con la operación para agregar un museo a la colección de museos.

Seleccione la colección a la izquierda de la pantalla y haga clic derecho sobre el nombre de la colección y seleccione add request. La llamaremos "Add a museum"

En los menu dropdown seleccionamos el tipo POST. En la URL dejamos el valor {{baseURL}}/museums.

Después vamos a la sección Body para documentar la representación del recurso museo en formato JSON.

Dentro de la sección Body seleccionamos la opción raw y allí seleccionamos el formato JSON. Después de eso agregamos el JSON con la representación del nuevo museo. Para este caso utilizaremos el siguiente JSON:

{
   "name": "Smithsonian national museum of natural history",
   "description": "The world's most popular natural history museum is dedicated to understanding the natural world and our place in it. Delve into the fascinating story of our planet, from its fiery beginnings through billions of years of transformation, and explore life on Earth through exhibitions and activities, collection objects and research that happens in the lab and in the field. The museum is larger than 18 football fields and is home to the largest natural history collection in the world.",
   "address": "10th St. & Constitution Ave. NW, Washington, DC",
   "city": "Washington DC",
   "image": "https://www.si.edu/sites/default/files/newsdesk/fact_sheets/nhb2015-02891.jpg"
}

La operación deberá verse configurada de la siguiente manera:

Al final guardamos los cambios haciendo clic en el botón Save.

Ahora documentamos el ejemplo de respuesta de esa petición. Hacemos clic en los tres puntos de la petición y seleccionamos Add example. El nombre lo dejamos igual al nombre de la petición. Luego en Body en la sección inferior colocaremos la respuesta que debe retornar el API después de crear un museo. El siguiente es un ejemplo de la respuesta esperada. Acá tenemos los mismos datos que enviamos al API junto con el id asignado por la base de datos.

{
   "id": "48a9ab90-1276-11ed-861d-0242ac120002",
   "name": "Smithsonian national museum of natural history",
   "description": "The world's most popular natural history museum is dedicated to understanding the natural world and our place in it. Delve into the fascinating story of our planet, from its fiery beginnings through billions of years of transformation, and explore life on Earth through exhibitions and activities, collection objects and research that happens in the lab and in the field. The museum is larger than 18 football fields and is home to the largest natural history collection in the world.",
   "address": "10th St. & Constitution Ave. NW, Washington, DC",
   "city": "Washington DC",
   "image": "https://www.si.edu/sites/default/files/newsdesk/fact_sheets/nhb2015-02891.jpg"
}

Definimos el Status Code para la operación de creación el cual debe ser 201 Created. Finalmente, hacemos clic en Save.

Obtener todos los museos

Agregamos un nueva operación a la colección haciendo clic derecho > Add request. El nombre será Get all museums. Es una petición de tipo GET y la URL es {{baseUrl}}/museums.

Ahora agregamos un ejemplo de la respuesta esperada. Como decisión de diseño se ha optado por usar la representación detallada del recurso que incluye sus atributos básicos (id, name, description, address, city e image) junto con las asociaciones con cardinalidad muchos que en este caso son artworks y exhibitions.

[
   {
       "id": "14f05d0e-1275-11ed-861d-0242ac120002",
       "name": "Bendigo Art Gallery",
       "description": "Located in Bendigo, Victoria, we are one of the oldest and largest regional galleries in Australia. Our collection is extensive, with an emphasis on 19th century European art and Australian art from the 1800s, alongside a strong collection of contemporary Australian art.\nOver the last decade, we have cemented a reputation for presenting innovative international exhibitions alongside a dynamic and varied suite of public programs and events.",
       "address": "42 View Street",
       "city": "Bendigo",
       "image": "https://www.bendigoregion.com.au/sites/default/files/styles/large/public/2019-05/Bendigo%20Art%20Gallery.jpg?itok=mbJ4vxuK",
       "artworks": [
           {
               "id": "14f05d0e-1275-11ed-861d-0242ac120032",
               "name": "Self portrait",
               "year": 1931,
               "description": "Painted in 1948, Cossington Smith's self-portrait represents her vibrant use of light-infused colour and interest in structure and form. Depicting herself in the prime of her long career, the short brushstrokes, laden with paint, build up a strong colour portrait and capture the dedication she felt towards her art in her intense focused gaze and the determined set of her lips.",
               "type": "Painting",
               "mainImage": "https://www.portrait.gov.au/files/b/b/2/c/i5398.jpg"
           },
           {
               "id": "14f05d0e-1275-11ed-861d-0242ac120004",
               "name": "Self portrait in the studio",
               "year": 1976,
               "description": "Similar to Brett Whiteley's other major paintings of this period, 'Self-portrait in the studio' exudes a sense of sumptuous living and the liquid presence of the harbour through what he called 'the ecstasy-like effect of Ultramarine blue'. Whiteley's tiny mirror self-portrait also reflects the influence of Eastern art in his portrayal of man as merely part of a larger landscape.",
               "type": "Painting",
               "mainImage": "https://www.bendigoregion.com.au/sites/default/files/2021-05/brett_whiteley_greg_self.jpg"
           },
           {
               "id": "14f05d0e-1275-11ed-861d-0242ac124032",
               "name": "Dogs",
               "year": 1975,
               "description": "Brett Whiteley felt deeply connected to animals since childhood. In fact, between 1965 and 1988 he staged four exhibitions whose predominant or exclusive subject was animals that he had observed in zoos, domestic environments and in nature.",
               "type": "Painting",
               "mainImage": "https://www.bendigoregion.com.au/sites/default/files/2021-05/brett_whiteley_greg_dogs.jpg"
           }
       ],
       "exhibitions": [
           {
               "id": "14f05d0e-1275-11ed-86dd-0242ac120032",
               "name": "Brett Whiteley: Drawing is Everything",
               "description": "At the heart of Brett Whiteley's extraordinary career was an exceptional talent for drawing.\nDrawing underpinned everything he did – from painting to sculpture to prints – and was fundamental to his imaginative and creative process. Whiteley's drawing is richly expressive and his bold mastery of line is instantly recognisable. \nThis major exhibition from the Art Gallery of New South Wales is the first to explore the central place of drawing in Whiteley's practice, featuring rarely seen early works from Sydney and Europe through to the great abstracts that brought Whiteley international fame in the 1960s. Also featured are lyrical landscapes, portraits, interiors and nudes and the iconic imagery of Sydney's Lavender Bay, offering a journey through the career that established him as one of the most prominent Australian artists of the 20th century.\nDon't miss this rare opportunity to discover the very foundations of Whiteley's creativity and process, as showcased in a collection of drawings, paintings, and sculptures suffused with the unmistakable personality of the great Australian master."
           },
           {
               "id": "14ffg05d0e-1275-11ed-861d-0242ac120032",
               "name": "Modern Australia",
               "description": "This selection of works from the Gallery's collection traces the key movements in Modern Australian art and design, and the search for a distinctive Australian visual arts style throughout the mid twentieth century."
           }
       ]
   },
   {
       "id": "14f05fgfd0e-1275-11ed-861d-0242ac120032",
       "name": "Museum of Modern Art",
       "description": "At The Museum of Modern Art and MoMA PS1, we celebrate creativity, openness, tolerance, and generosity. We aim to be inclusive places— both onsite and online—where diverse cultural, artistic, social, and political positions are welcome. We're committed to sharing the most thought-provoking modern and contemporary art, and hope you will join us in exploring the art, ideas, and issues of our time.",
       "address": "11 West 53 Street, Manhattan",
       "city": "New York City",
       "image": "https://media.cntraveler.com/photos/5dae0325b45cd80008161cf3/master/pass/MOMA-2019_IVRPHOTO-4373_ArtistChoice_HB_007-2-2000x1125.jpg",
       "artworks": [
           {
               "id": "14fgff05d0e-1275-11ed-861d-0242ac120032",
               "name": "Connaissance du monde",
               "year": 1996,
               "description": "In the late 1970s, after decades of making handwritten manuscripts, Bouabré began to draw on found cardboard, combining image and text. From the 1980s onwards, as the scope of his interests grew, he embarked on an all-encompassing project, drawing from observation almost daily. He titled the open-ended series of drawings Connaissance du Monde, and worked on it until his death in 2014, systematically compiling and classifying forms, ideas, and a wide range of phenomena, including domestic objects, cloud formations, and tribal scarifications, as well as the political climate and world events.",
               "type": "Painting",
               "mainImage": "https://universes.art/fileadmin/_processed_/2/b/csm_14_ivory_coast_16b2369926.jpg"
           }
       ],
       "exhibitions": [
           {
               "id": "14f05d0e-127fg5-11ed-861d-0242ac120032",
               "name": "Frédéric Bruly Bouabré: World Unbound",
               "description": "The work of the Ivorian artist Frédéric Bruly Bouabré had a single objective: to record and transmit information about the known universe. Devoting his life to a quest for knowledge, Bouabré captured and codified subjects from a range of sources, including cultural traditions, folklore, religious and spiritual belief systems, philosophy, and popular culture. "I do not work from my imagination,\" he once said. "I observe, and what I see delights me.""
           }
       ]
   }
]

Pegaremos esta opción de respuesta y seleccionaremos el tipo de respuesta como JSON. Adicionalmente, definiremos el Status Code en 200 OK. Solo quedaría guardar y ya estaría lista la petición junto con su ejemplo.

Obtener un museo

Es una petición de tipo GET, el nombre es Get one museum y la URL es {{baseUrl}}/museums/{{museum_id}}. Para no dejar un valor específico de un id en la petición usamos una variable denominada {{museum_id}}.

Ahora agregamos un ejemplo de la respuesta esperada. Como decisión de diseño también se ha definido que la respuesta sea la representación detallada del recurso.

Este es el el ejemplo de la respuesta:

{
   "id": "1e061964-1276-11ed-861d-0242ac120002",
   "name": "Museum of Modern Art",
   "description": "At The Museum of Modern Art and MoMA PS1, we celebrate creativity, openness, tolerance, and generosity. We aim to be inclusive places— both onsite and online—where diverse cultural, artistic, social, and political positions are welcome. We're committed to sharing the most thought-provoking modern and contemporary art, and hope you will join us in exploring the art, ideas, and issues of our time.",
   "address": "11 West 53 Street, Manhattan",
   "city": "New York City",
   "image": "https://media.cntraveler.com/photos/5dae0325b45cd80008161cf3/master/pass/MOMA-2019_IVRPHOTO-4373_ArtistChoice_HB_007-2-2000x1125.jpg",
   "artworks": [
       {
           "id": "2e061964-1276-11ed-861d-0242ac120002",
           "name": "Connaissance du monde",
           "year": 1996,
           "description": "In the late 1970s, after decades of making handwritten manuscripts, Bouabré began to draw on found cardboard, combining image and text. From the 1980s onwards, as the scope of his interests grew, he embarked on an all-encompassing project, drawing from observation almost daily. He titled the open-ended series of drawings Connaissance du Monde, and worked on it until his death in 2014, systematically compiling and classifying forms, ideas, and a wide range of phenomena, including domestic objects, cloud formations, and tribal scarifications, as well as the political climate and world events.",
           "type": "Painting",
           "mainImage": "https://universes.art/fileadmin/_processed_/2/b/csm_14_ivory_coast_16b2369926.jpg"
       }
   ],
   "exhibitions": [
       {
           "id": "1c061964-1276-11ed-861d-0242ac120002",
           "name": "Frédéric Bruly Bouabré: World Unbound",
           "description": "The work of the Ivorian artist Frédéric Bruly Bouabré had a single objective: to record and transmit information about the known universe. Devoting his life to a quest for knowledge, Bouabré captured and codified subjects from a range of sources, including cultural traditions, folklore, religious and spiritual belief systems, philosophy, and popular culture. "I do not work from my imagination,\" he once said. "I observe, and what I see delights me.""
       }
   ]
}

El código de estado será 200.

Obtener un museo que no existe

Esta operación se documentará para que el usuario entienda cómo el API notifica un error que se produce al generar una petición sobre un recurso que no existe.

Es una petición de tipo GET, el nombre es Get an invalid museum y la URL es {{baseUrl}}/museums/00000000-0000-0000-0000-000000000000. Por convención ese id no existe en la base de datos.

Ahora agregamos un ejemplo de la respuesta esperada.

{
   "statusCode": 404,
   "message": "The museum with the given id was not found"
}

Adicionalmente se debe colocar un Status Code 404 Not Found.

Actualizar un museo

Es una petición de tipo PUT, el nombre es Update a museum y la URL es {{baseUrl}}/museums/{{museum_id}}. Dentro de Body en formato JSON incluiremos la información del museo con los valores que se van a modificar:

{
   "name": "Smithsonian national museum of natural history",
   "description": "The world's most popular natural history museum is dedicated to understanding the natural world and our place in it. Delve into the fascinating story of our planet, from its fiery beginnings through billions of years of transformation, and explore life on Earth through exhibitions and activities, collection objects and research that happens in the lab and in the field. The museum is larger than 18 football fields and is home to the largest natural history collection in the world.",
   "address": "10th St. & Constitution Ave. NW, Washington, DC (new address)",
   "city": "Washington DC",
   "image": "https://www.si.edu/sites/default/files/newsdesk/fact_sheets/nhb2015-02891.jpg"
}

Como se observa el atributo que se modificó fue address y se agregó al final de la dirección el texto new address.

Crearemos ahora un ejemplo de respuesta por parte del servidor. En el cuerpo de la respuesta incluimos la representación básica del museo en formato JSON con los cambios aplicados. Definimos el Status Code 200 OK.

{
   "id": "144602ac-1278-11ed-861d-0242ac120002",
   "name": "Smithsonian national museum of natural history",
   "description": "The world's most popular natural history museum is dedicated to understanding the natural world and our place in it. Delve into the fascinating story of our planet, from its fiery beginnings through billions of years of transformation, and explore life on Earth through exhibitions and activities, collection objects and research that happens in the lab and in the field. The museum is larger than 18 football fields and is home to the largest natural history collection in the world.",
   "address": "10th St. & Constitution Ave. NW, Washington, DC (new address)",
   "city": "Washington DC",
   "image": "https://www.si.edu/sites/default/files/newsdesk/fact_sheets/nhb2015-02891.jpg"
}

Actualizar un museo que no existe

Es una petición de tipo PUT, el nombre es Update an invalid museum y la URL es {{baseUrl}}/museums/00000000-0000-0000-0000-000000000000. Dentro de Body en formato JSON incluiremos la información del museo con los valores que se van a modificar:

Como respuesta de ejemplo tendremos el siguiente JSON.

{
   "statusCode": 404,
   "message": "The museum with the given id was not found"
}

Se definirá el Status Code en el valor 404 Not Found.

Borrar un museo

Es una petición de tipo DELETE, el nombre es Delete a museum y la URL es {{baseUrl}}/museums/{{museum_id}}.

En la respuesta de ejemplo solo esperamos que el API retorne el código 204 No Content.

Borrar un museo que no existe

Es una petición de tipo DELETE, el nombre es Delete an invalid museum y la URL es {{baseUrl}}/museums/00000000-0000-0000-0000-000000000000.

Como respuesta del servidor esperamos el siguiente mensaje en formato JSON:

{
   "statusCode": 404,
   "message": "The museum with the given id was not found"
}

Adicionalmente se configura un Status Code 404 Not Found.

En la documentación del API no se deben tener en cuenta únicamente los recursos individuales sino también sus asociaciones. Para nuestro caso de estudio el recurso museo tiene una asociación con el recurso obras de arte. Esto implica que crearemos una colección adicional para esa documentación, que la llamaremos Museums-Artworks.

Las peticiones que incluiremos en esta colección son las siguientes:

Agregar una obra de arte a un museo

Este request lo llamaremos Add an artwork to a museum. Es una petición de tipo POST y la URL es:

{{baseUrl}}/museums/{{museum_id}}/artworks/{{artwork_id_1}}.

Las variables museum_id y artwork_id_1 representan los ids del museo y la obra de arte respectivamente.

Aunque esta es una petición de tipo POST no incluye un body.

Se espera que en la respuesta el API retorne el museo al que se le agregado la nueva obra de arte. Esta será la documentación de la respuesta junto con el código 201 Created.

{
   "id": "d48e0c39-e498-4244-8967-6cb96f7ed50f",
   "name": "Smithsonian national museum of natural history",
   "description": "The world's most popular natural history museum is dedicated to understanding the natural world and our place in it. Delve into the fascinating story of our planet, from its fiery beginnings through billions of years of transformation, and explore life on Earth through exhibitions and activities, collection objects and research that happens in the lab and in the field. The museum is larger than 18 football fields and is home to the largest natural history collection in the world.",
   "address": "10th St. & Constitution Ave. NW, Washington, DC",
   "city": "Washington DC",
   "image": "https://www.si.edu/sites/default/files/newsdesk/fact_sheets/nhb2015-02891.jpg",
   "artworks": [
       {
           "id": "b4584528-7a09-4634-80d8-2bc5e28d0cce",
           "name": "La Femme qui pleure",
           "year": 1837,
           "description": "The Weeping Woman, I is an elaboration of one of the central figures in Picasso's famous mural-size painting Guernica, executed some months earlier.",
           "type": "Painting",
           "mainImage": "https://assets.catawiki.nl/assets/2019/3/7/2/f/5/2f5c8a17-0b06-4f26-b4a7-4fa51a430ce1.jpg"
       }
   ],
   "exhibitions": []
}

Agregar una obra de arte que no existe a un museo

Este request lo llamaremos Add an invalid artwork to a museum. Es una petición de tipo POST y la URL es:

{{baseUrl}}/museums/{{museum_id}}/artworks/00000000-0000-0000-0000-000000000000

Se espera que en la respuesta el API retorne el código 404 junto con el mensaje descriptivo del error.

{
   "statusCode": 404,
   "message": "The artwork with the given id was not found"
}

Agregar una obra de arte a un museo que no existe

Este request lo llamaremos Add an artwork to an invalid museum. Es una petición de tipo POST y la URL es:

{{baseUrl}}/museums/00000000-0000-0000-0000-000000000000/artworks/{{artwork_id_1}}.

Se espera que en la respuesta el API retorne el código 404 junto con el mensaje descriptivo del error.

{
   "statusCode": 404,
   "message": "The museum with the given id was not found"
}

Obtener una obra de arte de un museo

Este request lo llamaremos Get an artwork of a museum. Es una petición de tipo GET y la URL es:

{{baseUrl}}/museums/{{museum_id}}/artworks/{{artwork_id_1}}

Se espera que en la respuesta el API retorne la obra de arte del museo junto con el código 200 Ok.

{
   "id": "7e265679-3a85-416d-afca-80fd04e2b79c",
   "name": "La Femme qui pleure",
   "year": 1837,
   "description": "The Weeping Woman, I is an elaboration of one of the central figures in Picasso's famous mural-size painting Guernica, executed some months earlier.",
   "type": "Painting",
   "mainImage": "https://assets.catawiki.nl/assets/2019/3/7/2/f/5/2f5c8a17-0b06-4f26-b4a7-4fa51a430ce1.jpg"
}

Obtener una obra de arte que no existe de un museo

Este request lo llamaremos Get an invalid artwork of a museum. Es una petición de tipo GET y la URL es:

{{baseUrl}}/museums/{{museum_id}}/artworks/00000000-0000-0000-0000-000000000000

Se espera que en la respuesta el API retorne el código 404 con un mensaje descriptivo del error.

{
   "statusCode": 404,
   "message": "The artwork with the given id was not found"
}

Obtener una obra de arte de un museo que no existe

Este request lo llamaremos Get an artwork of an invalid museum. Es una petición de tipo GET y la URL es:

{{baseUrl}}/museums/00000000-0000-0000-0000-000000000000/artworks/{{artwork_id_1}}

Se espera que en la respuesta el API retorne el código 404 con un mensaje descriptivo del error.

{
   "statusCode": 404,
   "message": "The museum with the given id was not found"
}

Obtener una obra de arte que no está asociada a un museo

Este request lo llamaremos Get an artwork non-associated to a museum. Es una petición de tipo GET y la URL es:

{{baseUrl}}/museums/{{museum_id}}/artworks/{{artwork_id_2}}

Note que en este caso se asume que el museo con el id {{artwork_id_2}} existe en la base de datos pero no se le ha asociado a ningún museo. Por tanto se espera que en la respuesta el API retorne el código 412 con un mensaje descriptivo del error.

{
   "statusCode": 412,
   "message": "The artwork with the given id is not associated to the museum"
}

Obtener las obras de arte de un museo

Este request lo llamaremos Get all artworks of a museum. Es una petición de tipo GET y la URL es:

{{baseUrl}}/museums/{{museum_id}}/artworks

Se espera que en la respuesta el API retorne el listado de obras del museo junto con el código 200.

[
   {
       "id": "28a6bcd5-7f74-4d31-ac70-456d0c520544",
       "name": "La Femme qui pleure",
       "year": 1837,
       "description": "The Weeping Woman, I is an elaboration of one of the central figures in Picasso's famous mural-size painting Guernica, executed some months earlier.",
       "type": "Painting",
       "mainImage": "https://assets.catawiki.nl/assets/2019/3/7/2/f/5/2f5c8a17-0b06-4f26-b4a7-4fa51a430ce1.jpg"
   }
]

Obtener las obras de arte de un museo que no existe

Este request lo llamaremos Get all artworks of an invalid museum. Es una petición de tipo GET y la URL es:

{{baseUrl}}/museums/00000000-0000-0000-0000-000000000000/artworks

Se espera que en la respuesta el API retorne el código 404 junto con el mensaje descriptivo del error.

{
   "statusCode": 404,
   "message": "The museum with the given id was not found"
}

Actualizar la lista de obras de un museo

Este request lo llamaremos Update artworks of a museum. Es una petición de tipo PUT y la URL es:

{{baseUrl}}/museums/{{museum_id}}/artworks

En el cuerpo de la petición se incluirá una lista con las nuevas obras que se agregarán al museo.

Este es el ejemplo del body. Por simplicidad tendremos una lista con una sola obra de arte y solo referenciaremos el id de esa nueva obra. Note que la obra de arte con el id artwork_id_2 que no estaba asignada inicialmente a ningún museo, ahora se asocia al museo existente.

[
   {
       "id": "{{artwork_id_2}}"
   }
]

Se espera que en la respuesta el API retorne el museo junto a las nuevas obras junto con el código 200 Ok.

{
   "id": "00519f14-2cd5-4a21-810d-39b06319bb54",
   "name": "Smithsonian national museum of natural history",
   "description": "The world's most popular natural history museum is dedicated to understanding the natural world and our place in it. Delve into the fascinating story of our planet, from its fiery beginnings through billions of years of transformation, and explore life on Earth through exhibitions and activities, collection objects and research that happens in the lab and in the field. The museum is larger than 18 football fields and is home to the largest natural history collection in the world.",
   "address": "10th St. & Constitution Ave. NW, Washington, DC",
   "city": "Washington DC",
   "image": "https://www.si.edu/sites/default/files/newsdesk/fact_sheets/nhb2015-02891.jpg",
   "artworks": [
       {
           "id": "c3039d8c-baaf-45f3-96de-7277936a374d",
           "name": "La Vie",
           "year": 1903,
           "description": "La Vie (Zervos I 179) is a 1903 oil painting by Pablo Picasso. It is widely regarded as the pinnacle of Picasso's Blue Period",
           "type": "Painting",
           "mainImage": "https://upload.wikimedia.org/wikipedia/en/thumb/1/11/La_Vie_by_Pablo_Picasso.jpg/800px-La_Vie_by_Pablo_Picasso.jpg"
       }
   ]
}

Actualizar las obras de arte que no existen de un museo

Este request lo llamaremos Update invalid artworks of a museum. Es una petición de tipo PUT y la URL es:

{{baseUrl}}/museums/{{museum_id}}/artworks

En el cuerpo de la petición se incluirá una lista con las nuevas obras que se agregarán al museo las cuales no deben existir.

Este es el ejemplo del body. Por simplicidad tendremos una lista con un sola obra de arte y solo referenciaremos el id de esa obra, la cual no existe.

[
   {
       "id": "00000000-0000-0000-0000-000000000000"
   }
]

Se espera que en la respuesta el API retorne el código 404 junto con el mensaje de error.

{
   "statusCode": 404,
   "message": "The artwork with the given id was not found"
}

Actualizar las obras de arte de un museo que no existe

Este request lo llamaremos Update artworks of an invalid museum. Es una petición de tipo PUT y la URL es:

{{baseUrl}}/museums/00000000-0000-0000-0000-000000000000/artworks

En el cuerpo de la petición se incluirá una lista con las nuevas obras que se agregarán al museo.

[
   {
       "id": "{{artwork_id_2}}"
   }
]

Se espera que en la respuesta el API retorne el código 404 junto con el mensaje de error.

{
   "statusCode": 404,
   "message": "The museum with the given id was not found"
}

Borrar una obra de arte de un museo

Este request lo llamaremos Delete an artwork of a museum. Es una petición de tipo DELETE y la URL es:

{{baseUrl}}/museums/{{museum_id}}/artworks{{artwork_id_2}}

Se espera que en la respuesta el API retorne el código 204.

Borrar una obra de arte de un museo que no existe

Este request lo llamaremos Delete an artwork of an invalid museum. Es una petición de tipo DELETE y la URL es:

{{baseUrl}}/museums/00000000-0000-0000-0000-000000000000/artworks/{{artwork_id_2}}.

Se espera que en la respuesta el API retorne el código 404 junto con el mensaje de error.

Borrar una obra de arte que no existe de un museo

Este request lo llamaremos Delete an invalid artwork of a museum. Es una petición de tipo DELETE y la URL es:

{{baseUrl}}/museums/{{museum_id}}/artworks/00000000-0000-0000-0000-000000000000

Se espera que en la respuesta el API retorne el código 404 junto con el mensaje de error.

Borrar la obra de arte que no está asociada a un museo

Este request lo llamaremos Delete an artwork non-associated to a museum. Es una petición de tipo DELETE y la URL es:

{{baseUrl}}/museums/{{museum_id}}/artworks/{{artwork_id_1}}

Se espera que en la respuesta el API retorne el código 412 junto con el mensaje de error.

Por defecto todas las colecciones quedan guardadas en el workspace del usuario, no obstante podemos guardarlas en el repositorio del proyecto.

Para esto debemos exportarlas a una carpeta del proyecto. Entonces, seleccionamos la colección, le damos clic derecho > Export.

En la ventana que aparece seleccionamos la versión v2.1 y hacemos clic en el botón Export.

Allí buscamos la carpeta collections en nuestro proyecto y guardamos el archivo. Asegúrese de que el nombre del archivo no contiene ni espacios ni caracteres especiales.