Skip to main content
PUT
/
interests
/
{id}
Update Interest
curl --request PUT \
  --url https://api.example.com/interests/{id} \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>"
}
'
{
  "message": "<string>"
}

Endpoint

PUT /interests/{id}

Description

Updates the name of an existing interest in the MayTravel system. This allows you to modify interest details while maintaining the same ID.

Request

Path Parameters

id
integer
required
The unique identifier of the interest to update

Headers

Content-Type: application/json

Body Parameters

name
string
required
The new name for the interest

Request Example

{
  "name": "Wildlife Photography"
}

Response

message
string
A success message confirming the update

Success Response (200 OK)

{
  "message": "Interest ID 5 data updated succesfully"
}

Error Response (500 Internal Server Error)

{
  "error": "Interest not found"
}
{
  "error": "name is required"
}
{
  "error": "Invalid interest ID"
}

Code Examples

const interestId = 5;

const response = await fetch(`http://your-api-base-url.com/interests/${interestId}`, {
  method: 'PUT',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'Wildlife Photography'
  })
});

const result = await response.json();
console.log(result.message);

Validation

  • The id parameter must be a valid integer
  • The interest with the specified ID must exist in the database
  • The name field is required in the request body
  • The new name should not be empty or null

Notes

  • Only the name field can be updated through this endpoint
  • The interest ID remains unchanged after the update
  • If the interest ID doesn’t exist, the operation will complete but no rows will be affected
  • Updating an interest will affect all users who have that interest associated with their profile

Build docs developers (and LLMs) love