securecloud@trend.com
NoteEach of these programming tasks assumes that you are you are using a new
programming code file. The examples shown are using Python programming language. Other
programming languages, such as C++ or Java, are capable of performing the same requests.
|
digest_broker_account = "test_digest_account" digest_password = "QTpYVL0QKI" digest_realm = "securecloud@trend.com"
pwd_mgr = urllib2.HTTPPasswordMgr() pwd_mgr.add_password(digest_realm, api_url, digest_broker_account, digest_password)
opener = urllib2.build_opener() opener.add_handler(urllib2.HTTPDigestAuthHandler(pwd_mgr))
req = urllib2.Request(api_url)
req.add_header('Content-Type', 'application/xml; charset=utf-8')
req.add_header('BrokerName', digest_broker_account)
NoteThe example shown here is merely a part of a total request. It will not execute properly
by itself. It is possible to use this content as an independent function to be called
in
other requests.
The API URL is a variable that will be defined in each independent function.
It is not defined generally here. In the example, this variable is
api_url.
|
# Create variables for each part of the broker account information.
digest_broker_account = "test_digest_account"
digest_password = "QTpYVL0QKI"
digest_realm = "securecloud@trend.com"
# Add broker account information and the API URL to the password manager in the same function.
pwd_mgr = urllib2.HTTPPasswordMgr()
pwd_mgr.add_password(digest_realm, api_url, digest_broker_account, digest_password)
# Add the broker account information and the API URL to the API request handler.
opener = urllib2.build_opener()
opener.add_handler(urllib2.HTTPDigestAuthHandler(pwd_mgr))
# Request the API using the API URL.
req = urllib2.Request(api_url)
# Set the request data type to XML format.
req.add_header('Content-Type', 'application/xml; charset=utf-8')
# Include the broker account information in the header.
req.add_header('BrokerName', digest_broker_account)