ユーザーの更新

このコードスニペットでは、ユーザの詳細を更新する方法を学びます。

以下の変数が、便利な方法で必要な値に設定されていることを確認してください:

キー説明
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.

Prerequisites

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.

Write the code

Add the following to 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'"
}'

View full source

Run your code

Save this file to your machine and run it:

bash update-user.sh

試してみる

コードを実行すると、指定したユーザの名前と表示名が更新されます。