Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This article will explain how to add N number of Users to a dashboard using Postman.

Postman

Postman is a free utility that works with API calls. We will use just 2 postman requests within a Postman Flow, alongside some control flow logic and a few variables to create as many users as you want.You can download & install or use the online version. Register and you’re away.

The Panintelligence dashboard contains an API which we will utilise.

Postman Flows

In essence, Postman Flows allow you to “string-together” postman requests.

Note

😱 Unfortunately Postman Flows CANNOT be shared on the free subscription, but

...

are

...

easy to create, so we are going to create it from scratch (smile)

We will use 2 postman requests within a Postman Flow, alongside some control flow logic and a few variables to create as many users as required.

Postman flows employ or reference existing postman collection requests, so before creating a flow we have to create the requests that we want to put in our flow.

...

There are just 2 Send Requests, one (1) is to logon onto the dashboard and get a token which is used as the authenticator in the other second call (2) which creates a user.

The create user send request is part of a repeating control flow that loops the number of times you have set the variable usersToCreate

The variable userNamePrefix is used as the prefix for all user names.

The variable StartAt sets the user number to start creating from.

Info

If you want to create 500 users starting at 1001 with a prefix of “TH_” eg “TH_1001” through to “TH_1500” then the variable values would be:

userType = 4 ( UserType: 0=Admin, 1=Designer, 2=Explorer, 3=User, 4=Viewer)

usersToCreate: 500

StartAt: 1001

userNamePrefix: TH_

...

Lets get started by creating a new Collection in Postman called Create Users

...

Now we We will then create the 2 POST requests, Get Token & Create User By Type

🛠️ Start Postman

Create a New Collection - Call it Create Users

  1. POST Get Token

    • Hover over the folder called Create Users, click the 3 dots and select Add Request which will create a request stub. Immediately rename it by hovering over the New Request, again click the 3 dots then click Rename and give it a name of Get Token

    • Change it to be a POST request

      Postman Create New Request.pngImage Added

    • Enter the URL - this is where the variables become useful, simply enter:

      • {{DASHBOARD_URL}}{{DASHBOARD_API_PATH}}/tokens

      • Set the Authentication Type to Basic and enter references to the variables in Username and Password.

        Postman Create New Request-Auth.pngImage Added
      • Add a little magic ! In the Scripts tab enter the code below which in simple terms grabs the dashboard token from the response of this POST request, which if we have supplied valid credentials, will have a value that we will capture and re-use in all subsequent API requests.

        • Code Block
          const jsonResponse = pm.response.json();
          pm.collectionVariables.set("DASHBOARD_TOKEN", jsonResponse.token);
Tip

Test by clicking the Send button (Top-Right) - this needs to respond with a status code of 200 and show the returned token.

  1.  POST Create User by Type

    • Hover over the folder called Create Users, click the 3 dots and select Add Request which will create a request stub. Immediately rename it by hovering over the New Request, again click the 3 dots then click Rename and give it a name of Create User by Type

    • Change it to be a POST request

      Postman Create New Request.pngImage Added

    • Enter the URL - this is where the variables become useful, simply enter:

      • {{DASHBOARD_URL}}{{DASHBOARD_API_PATH}}/users

      • Set the Authentication Type to Bearer Token and enter references to the variable {{bearerToken}} in the Token.

        image-20241104-134502.pngImage Added

      • Set the content Body. Click the Body tab, then click Raw and enter JSON for creating a user.

        image-20241104-135234.pngImage Added
        Code Block
        {
          "clientEnabled": true,
          "usercode": {{userNamePrefix}}{{currUserNum}},
          "userTypeId": {{userType}}, 
          "parentId": {{parentId}},
          "surname": {{userNamePrefix}},
          "forenames": "{{currUserNum}}",
          "email": {{userNamePrefix}}{{currUserNum}}"@panintelligence.com",
          "orgId": {{orgId}},
          "clientPassword": "password",
          "forceChangingPassword": false,
          "allowPasswordLogin": true,
          "allowExternalLogin": true,
          "clientExcludePasswordExpiry": true,
          "themeName": null,
          "requireMfa": false,
          "userExpirationDate": null,
          "lite": false,
          "canLogInAsAnotherUser": true, 
        //ADMIN USERTYPE = 0
          "editApis": true, 
          "editCategories": true,
          "editConnections": true,
          "editRoles": true,
          "editServerSettings": true,
          "editThemes": true,
          "editUsers": true,
          "editVariables": true,
          "editUserAccess": true,
        //DESIGNER USERTYPE = 1
          "saveLayouts": true,
          "editSql": true,
          "editChartStyles": true,
          "anonymousCharts": true,
        //CHART EXPLORER USERTYPE = 2
          "editCharts": true,
        //USER USERTYPE = 3
          "collaborate": true,
          "editReports": true,
          "modifyLayouts": true,
          "saveFilters": true,
          "schedule": true,
          "scheduleToEmail": true,
        //VIEWER USERTYPE = 4
          "accessAccount": true,
          "addTempCategoryObjects": true,
          "applySavedFilters": true,
          "editOwnPassword": true,
          "editOwnStylesheet": true,
          "logoutEnabled": true,
          "carousel": true,
          "carouselForDashboard": true,
          "carouselForCategory": true,
          "enableWarnings": true,
          "enableDebugging": true,
          "displayChartInfo": true,
          "canViewChartInfoDetails": true,
          "canViewChartEmbeddingLink": true,
          "displayDisabledButtons": true,
          "audit": true,
          "exportToCsv": true,
          "exportToExcel": true,
          "Pdf": true,
          "exportToPpt": true,
          "exportToWord": true
        }

The above JSON will grant ALL privileges for each User Type. Some user details are set via variables including the UserType, so setting userType in the flow to 4 will create a VIEWER User with ALL viewer privileges, setting userType to 0 will create an ADMINISTRATOR with ALL privileges.

\uD83D\uDCCB Related articles

DevOps Pipeline - pi Documentation - Confluence