Demystifying iControl REST Part 5: Transferring Files
Updated Aug 04, 2023
Version 5.0Was this article helpful?
@Jason
I tried it out and got an error
For the simple test, I placed a key file under/var/config/rest/downloads/mynew_key.key and then made the following call from Windows IDLE(3.6.2):
from f5.bigip import ManagementRoot
import requests
import sys
import os
requests.packages.urllib3.disable_warnings()
mr = ManagementRoot('x.x.x.x', 'admin', 'admin')
key = mr.tm.sys.file.ssl_keys.ssl_key.create(name='MyNewkey', partition='Common', sourcePath='/var/config/rest/downloads/mynew_key.key')
Then I got the following error.
Traceback (most recent call last):
File "C:\Users\xyz\Documents\Python Practice\ssl cert key file upload.py", line 23, in
key = mr.tm.sys.file.ssl_keys.ssl_key.create(name='MyNewkey', partition='Common', sourcePath='/var/config/rest/downloads/mynew_key.key')
File "C:\Users\xyz\AppData\Local\Programs\Python\Python36-32\lib\site-packages\f5\bigip\resource.py", line 974, in create
return self._create(**kwargs)
File "C:\Users\xyz\AppData\Local\Programs\Python\Python36-32\lib\site-packages\f5\bigip\resource.py", line 941, in _create
response = session.post(_create_uri, json=kwargs, **requests_params)
File "C:\Users\xyz\AppData\Local\Programs\Python\Python36-32\lib\site-packages\icontrol\session.py", line 272, in wrapper
raise iControlUnexpectedHTTPError(error_message, response=response)
icontrol.exceptions.iControlUnexpectedHTTPError: 400 Unexpected Error: Bad Request for uri: https://x.x.x.x:443/mgmt/tm/sys/file/ssl-key/
Text: '{"code":400,"message":"Failed! exit_code (3).\\n","errorStack":[],"apiError":26214401}'
any idea?