Update a User
In this code snippet you learn how to update a User's details.
Example
Ensure the following variables are set to your required values using any convenient method:
| Key | Description |
|---|---|
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.
Run your code
Save this file to your machine and run it:
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.
Create a file named update-user.js and add the following code:
Run your code
Save this file to your machine and run it:
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.
Add the following to build.gradle:
Create a file named UpdateUser and add the following code to the main method:
Run your code
We can use the application plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
Run the following gradle command to execute your application, replacing com.vonage.quickstart.kt.users with the package containing UpdateUser:
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.
Add the following to build.gradle:
Create a file named UpdateUser and add the following code to the main method:
Run your code
We can use the application plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
Run the following gradle command to execute your application, replacing com.vonage.quickstart.users with the package containing UpdateUser:
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.
Create a file named UpdateUser.cs and add the following code:
using System;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Vonage;
using Vonage.Request;
using Vonage.Users.UpdateUser;Add the following to UpdateUser.cs:
var credentials = Credentials.FromAppIdAndPrivateKeyPath(VONAGE_APPLICATION_ID, VONAGE_PRIVATE_KEY_PATH);
var client = new VonageClient(credentials);Write the code
Add the following to UpdateUser.cs:
var response = await client.UsersClient.UpdateUserAsync(UpdateUserRequest.Build()
.WithId(USER_ID)
.WithName(USER_NAME)
.WithDisplayName(USER_DISPLAY_NAME)
.Create());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.
Run your code
Save this file to your machine and run it:
Try it out
When you run the code you will update the name and display name of the specified User.