I just testet with SBC 5000, it does not work, as - perhaps only in my case - the SBC does not use this login URL above:
fertig@hornisse:..projects/sbc > python3 ribbonapitest.py
Traceback (most recent call last):
File "ribbonapitest.py", line 64, in <module>
sys.exit(main())
File "ribbonapitest.py", line 45, in main
session = session_creator()
File "ribbonapitest.py", line 37, in session_creator
open_response = session.open()
File "/home/fertig/projects/sbc/pyribbon.py", line 21, in open
response.raise_for_status()
File "/usr/lib/python3.6/site-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: for url: https://192.xxx.xxx.xxx/rest/login
fertig@hornisse:..projects/sbc >
import requests
import xmltodict
import json
import pprint
import sys
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
sbc = "192.xxx.xxx.xxx"
username = "restapitest"
password = "xxxxxxxxxxxxxxxxxxxx"
url = 'https://%s/api/config/addressContext/' % sbc
headers = {}
try:
r = requests.get(url, headers=headers, auth=(username, password), verify=False)
# print r.status_code, r.history
except Exception, why:
print "error contacting sbc:", why
sys.exit(1)
responsedict = {}
if r.ok:
responsedict = dict(xmltodict.parse(r.text))
print(json.dumps(responsedict, indent=4))
If you're still working on this code, perhaps I could help you extend this for SBC 5000