I saw on a devcentral post that it was necessary to add file: to the pathfile.
curl -sku admin:admin -X POST https://x.x.x.x/mgmt/tm/sys/file/ssl-cert -H 'Content-Type: application/json' -d '{"name":"testcsr.crt","partition": "Common","sourcePath":"file:/var/www/html/certs/certificats/files/test_certificate.pem"}'
{
"code": 400,
"message": "Failed! exit_code (37).\n",
"errorStack": [],
"apiError": 26214401
}
from f5.bigip import ManagementRoot
# Connect to the BIG-IP
mgmt = ManagementRoot("x.x.x.x", "admin", "admin")
cert = mgmt.tm.sys.file.ssl_certs.ssl_cert.create(name='test_cert', sourcePath='file:/var/www/html/certs/certificats/files/test_certificate.pem')
Traceback (most recent call last):
File "/root/test-f5-api.py", line 22, in <module>
cert = mgmt.tm.sys.file.ssl_certs.ssl_cert.create(name='test_cert', sourcePath='file:/var/www/html/certs/certificats/files/test_certificate.pem')
File "/root/f5-common-python/f5/bigip/resource.py", line 1053, in create
return self._create(**kwargs)
File "/root/f5-common-python/f5/bigip/resource.py", line 1015, in _create
response = session.post(_create_uri, json=kwargs, **requests_params)
File "/usr/local/lib/python3.9/site-packages/icontrol/session.py", line 295, in wrapper
raise iControlUnexpectedHTTPError(error_message, response=response)
icontrol.exceptions.iControlUnexpectedHTTPError: 400 Unexpected Error: Bad Request for uri: https://lbaind2itvpx101-adm.nor.fr.intraorange:443/mgmt/tm/sys/file/ssl-cert/
Text: '{"code":400,"message":"Failed! exit_code (37).\\n","errorStack":[],"apiError":26214401}'
it would be a problem of rights or other API but I don't know where?