Updated on September 14, 2023

Update an actor

PATCH

You can modify the details of an existing actor in the Monolito Movies database using the Monolito Movies API. This document provides instructions on how to make a PATCH request to update actor information.

Endpoint

To update an actor, make a PATCH request to the following endpoint:

PATCH /actors/{actor_id}

Replace {actor_id} with the unique identifier of the actor you want to update.

Request

Here's an example of how to make a PATCH request to update actor information using JavaScript:

const actorId = 789; // Replace with the actual actor ID
const updatedActorData = {
  name: "Updated Actor Name",
  birthdate: "YYYY-MM-DD",
  nationality: "Updated Nationality (optional)",
  biography: "Updated Actor Biography (optional)"
};

const apiUrl = `https://api.monolitomovies.com/v1/actors/${actorId}`;

fetch(apiUrl, {
  method: "PATCH",
  headers: {
    "Content-Type": "application/json"
  },
  body: JSON.stringify(updatedActorData)
})
  .then(response => response.json())
  .then(data => {
    console.log("Actor Updated:", data);
  })
  .catch(error => {
    console.error("Error:", error);
  });

In this example, we use the fetch function to make an HTTP PATCH request to the specified API endpoint. Replace 789 with the actual actor ID you want to update and provide the updated actor data.

Response

Upon successful update, the API will respond with the updated actor's details in JSON format, including any changes made to the actor's information.

Response Example

{
  "id": 789,
  "name": "Updated Actor Name",
  "birthdate": "YYYY-MM-DD",
  "nationality": "Updated Nationality (optional)",
  "biography": "Updated Actor Biography (optional)"
}

You can now update actor details as needed using the Monolito Movies API. Next, we'll cover how to delete an actor from the database.