• Nikhil Verma

How to connect Vmware Horizon 8.0 using REST API

From Horizon 7.10 we are seeing Horizon REST API which is very useful in automation and reporting.

Purpose of this Blog :

=> How to generate token in Horizon REST API

=> How to get information with the help of token's , this would helpful for reporting.

=> How to make changes using restful API's.

Generate Horizon REST token:

import requests
import json

url = "https://horzionserver/rest/login"
data1 = {
    "username": "username",
    "password": "password",
    "domain": "domain"

headers = {'Content-type': 'application/json'}

auth_response =,verify=False,headers=headers,data=json.dumps(data1))


auth_response_json = auth_response.json()

auth_token = auth_response_json["access_token"]

refresh_token = auth_response_json["refresh_token"]

Get Info about Environment properties using REST API

url2 = "https://horizonserver/rest/config/v1/environment-properties"

env_settings = requests.get(url2,verify=False,headers={"Authorization":"Bearer " + auth_token})

Get General settings info :

url3 = "https://horizonserver/rest/config/v1/settings/general"

headtest = {
    'Content-type': 'application/json',
    'Authorization':'Bearer ' + auth_token
gen_settings = requests.get(url3,verify=False,headers=headtest)

Now we will change General settings "Hide domain list in client" :

url3 = "https://horizonserver/rest/config/v1/settings/general"

headtest = {
    'Content-type': 'application/json',
    'Authorization':'Bearer ' + auth_token

payload ={
    "client_max_session_timeout_policy": "NEVER",
    "client_idle_session_timeout_policy": "NEVER",
    "client_session_timeout_minutes": 1200,
    "display_pre_login_message": False,
    "enable_server_in_single_user_mode": False,
    "console_session_timeout_minutes": 480,
    "enable_automatic_status_updates": False,
    "enable_sending_domain_list": False,
    "enable_credential_cleanup_for_htmlaccess": True,
    "hide_server_information_in_client": False,
    "hide_domain_list_in_client": True,
    "display_warning_before_forced_logoff": True,
    "forced_logoff_timeout_minutes": 5,
    "forced_logoff_message": "Your desktop is scheduled for an important update and will shut down in 5 minutes. Please save any unsaved work now",
    "enable_multi_factor_re_authentication": False,
    "block_restricted_clients": True,
    "restricted_client_data": [
            "type": "WINDOWS",
            "version": "xxx"
    "machine_sso_timeout_policy": "DISABLED_AFTER",
    "machine_sso_timeout_minutes": 15,
    "application_sso_timeout_policy": "ENABLED",
    "store_cal_on_connection_server": True,
    "store_cal_on_client": True

r = requests.put(url3,verify=False,data= json.dumps(payload),headers=headtest)

gen_settings = requests.get(url3,verify=False,headers=headtest)

9 views0 comments

Recent Posts

See All
  • Grey Twitter Icon
  • Grey LinkedIn Icon
  • Grey Facebook Icon
  • Twitter Social Icon
  • LinkedIn Social Icon
  • Facebook Social Icon