Agile Central: WSAPI - How to create a user with profile image using WSAPI

Document ID : KB000100862
Last Modified Date : 12/06/2018
Show Technical Document Details
How can we use WSAPI to create a User along with uploading his Profile Image file?
Let's walk through the process of using WSAPI to create a User along with setting up his username avatar.

Step 1
Let's examine WSAPI object model to find what needs to be done.

The User endpoint shall be used to create the User, see its methods:
User-added image

We will scroll down the fields and find all the required attributes. We shall also look for the user's profile image field.
User-added image

This field refers us to another REST Endpoint, named: ProfileImage. Let's examine that endpoint:
User-added image

We realize we need to convert the user's profile image file to a 'base64Binary' format.

Step 2
Let's convert our profile image file to a base64Binary format.

To do that, let's use one (of many) freely available online site:

Here is our user's profile image file:

User-added image

On the website, let's upload this file and click Convert to Base64:
User-added image

Now, before we continue, let's test our conversion. So, let's convert it back from the base64Binary back to an image file. To do that , we shall use another freely available website (of many):

Let's copy the text we have from our first site. Then, in the second site, let's paste the text and click to Generate Image:

User-added image

Looks good. So we now know our converted base64Binary text from the first site is good.

Step 3
Let's use WSAPI to create the User and ProfileImage objects. These are two separate objects whereas the User references the ProfileImage. Therefore, we shall first create the ProfileImage object, then use its ObjectID to set it to our new User.

- We'll use the ProfileImage endpoint:
User-added image

Let's confirm the result and get the ObjectID:
User-added image

- We'll now create the User and include the ProfileImage field set to the ObjectID we just received:
User-added image

Let's check the result:
User-added image

All is looking well.

Step 4
Let's now check out Agile Central, locate our newly created user and see their profile image:

User-added image

Bring up the user's profile and... 
User-added image

Our Profile Image is there.
Additional Information:
More on WSAPI: