07-24-2019 11:56 AM
Hello,
I have a cisco IronPort with q AsyncOS 12.0, and I have questions about how to use the API.
I looked at the documentation https://www.cisco.com/c/en/us/td/docs/security/security_management/sma/sma12-0/api/b_SMA_API_12/test_chapter_01.html, but I didn't understand how to connect and consume the data from API.
I ran the command curl -X GET --header 'Accept: application / json' -u {user =: pass} 'myip.com:6080/sma/api/v2.0/login' and got the following error:
{"error": {"message": "Unsupported method ('POST').", "code": "501", "explanation": "501 = Server does not support this operation."}} [root @ xxxxxx ironport] #
How can I do this communication using Python?
Solved! Go to Solution.
08-12-2019 09:22 AM
Hello,
Postman can still be useful as it will allow you to export the request in multiple ways (one being cURL) which can be used elsewhere.
As an example, you could do something like this :
curl -sk -u admin:password https://<IPorFQDN>:<api-port>/sma/api/v2.0/config/system_time?device_type=sma
{"data": {"timezone": "America/New_York", "continent": ["America", "United States", "New_York"], "time": "Mon Aug 12 12:18:07 2019 EDT"}}
Thanks!
-Dennis M.
07-31-2019 05:22 AM
Review here to see if this helps:
AsyncOS REST API 2.0: Using AsyncOS REST API 2.0 with External/3rd Party API Environments
08-11-2019 10:49 AM
Hi Robert
Thanks for the help, but it's not exactly what I need. I can't use postman because only a Linux server has access to ironPort's Cisco Appliance.
Could you make these inquiries with curl or pytohn?
How do I use this example above?
Sample Request
POST /sma/api/v2.0/login
HTTP/1.1
Content-Type: application/json
cache-control: no-cache
User-Agent: curl/7.54.0
Accept: */*
Host: sma.cisco.com:6080
accept-encoding: gzip, deflate
content-length: 95
Connection: keep-alive
{
"data":
{
"userName":"YWRtaW4=",
"passphrase":"aXJvbnBvcnQ="
}
}
Testei com o curl com o exemplo abaixo, mas apresenta erro:
curl -i -X GET --header 'Accept: application/json' http://localhost:6080/sma/api/v2.0/login -u admin:admin
HTTP/1.0 401 Permission denied
Server: EmailAPI/1.0
Date: Sun, 11 Aug 2019 17:48:26 GMT
Content-Type: application/json
Connection: close
{"error": {"message": "Permission denied.", "code": "401", "explanation": "401 = No permission -- see authorization schemes."}}
08-12-2019 09:22 AM
Hello,
Postman can still be useful as it will allow you to export the request in multiple ways (one being cURL) which can be used elsewhere.
As an example, you could do something like this :
curl -sk -u admin:password https://<IPorFQDN>:<api-port>/sma/api/v2.0/config/system_time?device_type=sma
{"data": {"timezone": "America/New_York", "continent": ["America", "United States", "New_York"], "time": "Mon Aug 12 12:18:07 2019 EDT"}}
Thanks!
-Dennis M.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide