curl --request PUT \
--url https://api.example.com/api/usuarios/:id/rol \
--header 'Content-Type: application/json' \
--data '
{
"role": "<string>"
}
'{
"message": "<string>",
"usuario": {
"id": "<string>",
"persona_id": 123,
"role": "<string>",
"created_at": "<string>"
}
}Update only the role of a specific user
curl --request PUT \
--url https://api.example.com/api/usuarios/:id/rol \
--header 'Content-Type: application/json' \
--data '
{
"role": "<string>"
}
'{
"message": "<string>",
"usuario": {
"id": "<string>",
"persona_id": 123,
"role": "<string>",
"created_at": "<string>"
}
}admin role.admin or asistente.curl -X PUT http://localhost:3000/api/usuarios/a1b2c3d4-e5f6-7890-abcd-ef1234567890/rol \
-H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"role": "admin"
}'
const response = await fetch(
'http://localhost:3000/api/usuarios/a1b2c3d4-e5f6-7890-abcd-ef1234567890/rol',
{
method: 'PUT',
headers: {
'Authorization': `Bearer ${adminToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
role: 'admin'
})
}
);
{
"message": "Rol actualizado",
"usuario": {
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"persona_id": 5,
"role": "admin",
"created_at": "2024-03-01T10:00:00.000Z"
}
}
400 Bad Request
{
"message": "Role es obligatorio"
}
role field was not provided in the request body.404 Not Found
{
"message": "Usuario no encontrado"
}
/home/daytona/workspace/source/src/routes/usuarios.routes.js:215