Hi there,
we have some Firepower 2130 that are running ASA code but in platform mode. To back up the interface config from the FXOS I'd like to use the FXOS REST API through a Python script.
However, when I try to log in and obtain a session token I always get error 400 (bad request).
Any ideas why it's not working?
Here's my code snipped:
def api_call(ip_addr, port, command, json_payload, sid):
url = 'https://' + ip_addr + ":" + str(port) + '/api/' + command
if sid == '':
request_headers = {'Content-Type' : 'application/json'}
else:
request_headers = {'Content-Type' : 'application/json', 'X-chkp-sid' : sid}
r = requests.post(url,data=json.dumps(json_payload), headers=request_headers, verify=False)
return r
def login(user, password):
payload = {'username': user,
'password': password}
command = "/api/login"
response = api_call(fp_ip, 443, command, payload, '')
return response
r = login(fxos_username, fxos_password)
print(r)