Most of the time I work with the vRealize Automation API through vRO Actions. Occasionally I have the need to make a change to the system which requires using the API. One such example is modifying the session timeout, as written by Gary at https://garyflynn.com/post/vrealize-automation-85-increase-session-timeout.
For something quick and simple like this I would use the excellent Postman client and a simple workflow. However, I recently took delivery of a new machine and had to set this up again as it wasn’t in my collection of requests.
Environment
In Postman, create a new environment for vRealize Automation and configuration the following variables:
Populate the FQDN and login details, then click Add to save the environment. Make sure the environment is selected in the top-right of the client.
Refresh Token
Open a new tab and set the following:
Method | POST |
URL | https://{{va-fqdn}}/csp/gateway/am/api/login?access_token |
Authorization | None (Inherit auth from parent) |
Headers | Accept: application/json Content-Type: application/json |
Body | { “username”: “{{username}}”, “password”: “{{password}}”, “domain”: “{{domain}}” } |
If entered correctly, the variables (va-fqdn, username, password and domain should all be highlighted orange).
Click on the Test tab and enter the following:
var response = pm.response.json(); | |
pm.environment.set("refresh_token", response.refresh_token); |
The above code will parse the response we receive, strip out the refresh token and set the environment variable with this value.
Click Send. You will notice that in the bottom pane, on the Body tab, a refresh token has been returned. You should also see this value in your environment variables by clicking on the eye icon to the right of your environment name.
Access Token
Create another tab, this time with the following details:
Method | POST |
URL | https://{{va-fqdn}}/iaas/api/login |
Authorization | None (Inherit auth from parent) |
Headers | Accept: application/json Content-Type: application/json |
Body | { “refreshToken”: “{{refresh_token}}” } |
Use the following for the test:
var response = pm.response.json(); | |
pm.environment.set("access_token", response.token); |
Click Send. You will notice the access token has been stored as a variable.
Make Your API Call
Open another tab, this time to make the API call of your choosing. I will use Gary’s post as an example:
Method | POST |
URL | https://{{va-fqdn}}/iaas/api/configuration-properties?apiVersion=2021-07-15 |
Authorization | None (Inherit auth from parent) |
Headers | Authorization: Bearer {{access_token}} Content-Type: application/json |
Body | { “key”: “SESSION_TIMEOUT_DURATION_MINUTES”, “value”: “1440” } |
In the above example, I have set my session timeout to twenty-four hours. Hope this helps!
Pingback: vExpert Cloud Management May 2022 Blog Digest - Möbius Business Technologies Ltd.