Forum Discussion
API REST error 400
Hello JRahm
Thank you for your answer but it does not work, I have another error.
Test done via curl and via python.
curl -sk -H "X-F5-Auth-Token: XXXXXX" -X POST https://x.x.x.x/mgmt/tm/sys/file/ssl-cert -H 'Content-Type: application/json' -d '{"name":"testcsr","partition": "Common","sourcePath":"/var/www/html/certs/certificats/files/test_certificate.pem"}'
{
"code": 400,
"message": "Failed! exit_code (3).\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='/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='/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://x.x.x.x:443/mgmt/tm/sys/file/ssl-cert/
Text: '{"code":400,"message":"Failed! exit_code (3).\\n","errorStack":[],"apiError":26214401}'
Do you have a working example?
Test carried out on an F5 in version 13.1.5 and in version 14.1.4.6 with the same result.
- Francois_LAGANTAug 25, 2022Nimbostratus
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?
- JRahmAug 25, 2022Admin
Looks like you're missing a letter in certificates in your source file path on quick glance.
on my phone with a break in daddy duty...can dig in a little later this morning once little man gets to preschool.
- Francois_LAGANTAug 25, 2022Nimbostratus
For me it's ok the names of the sources are ok
-rwxrwxrwx. 1 apache apache 2061 Aug 24 09:57 /var/www/html/certs/certificats/files/test_certificate.pem
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com