much latency for some use cases. To mitigate this, the
API supports a session-based authentication mechanism.
To open a session, issue a POST to http://<ip-
address>/xmlapi/session/begin with basic access
authentication. The response sets a SessionId-cookie that
can be used with subsequent requests.
Note that when using API session authentication, it is
important to explicitly close the session when you are
done. Failing to do so may cause the device to run out of
sessions, as a limited number of concurrent sessions are
available, and they do not time out automatically.
Creating a Session
You create a session by sending an xAPI session request
to the endpoint. Example 10-18 shows a simple Python
POST request, to which the server responds with the
session cookie.
Example 10-18 Python Script to Get a Session Cookie
Click here to view code image
""" Webex Devices - Get Session Cookie """
import requests
URL =
"http://10.10.20.159/xmlapi/session/begin"
HEADERS = {
'Authorization': "Basic
ZGV2YXNjOkMxc2NvITIz"
}
RESPONSE = requests.request("POST", URL,
headers=HEADERS)
print(RESPONSE.headers["Set-Cookie"])
The corresponding response header contains the session
cookie, as shown in Example 10-19.
Example 10-19 Response Header Containing the
Session Cookie