Actualizar un usuario

En este fragmento de código aprenderá a actualizar los datos de un usuario.

Ejemplo

Asegúrese de que las siguientes variables se ajustan a los valores requeridos utilizando cualquier método conveniente:

ClaveDescripción
USER_ID

The unique ID of the User.

USER_NEW_NAME

The new name of the User.

USER_NEW_DISPLAY_NAME

The new display name of the User.

Requisitos previos

You will need to use an existing Application and have a User in order to be able to update a User. See the Create Conversation code snippet for information on how to create an Application. See also the Create User code snippet on how to create a User.

Escriba el código

Añada lo siguiente a update-user.sh:

curl -X "PATCH" "https://api.nexmo.com/v1/users/$USER_ID" \
     -H 'Authorization: Bearer '$JWT\
     -H 'Content-Type: application/json' \
     -d $'{
  "name": "'$USER_NAME'",
  "display_name": "'$USER_DISPLAY_NAME'"
}'

Ver fuente completa

Ejecute su código

Guarde este archivo en su máquina y ejecútelo:

bash update-user.sh

Pruébalo

Cuando ejecute el código actualizará el nombre y el nombre para mostrar del Usuario especificado.