Cheetsheet API
REST_API.txt
Created an auth.json file:
{
"Username": "sdkuser",
"Password": "supersecretpassword"
}
YAML snippet in my lab:
...
tasks:
- name: Authenticate & retrieve APIKEY
uri:
url: https://{{ sdkurl }}/vedsdk/Authorize/
method: POST
headers:
Content-Type: "application/json"
body: "{{ lookup('file','auth.json') }}"
body_format: json
validate_certs: no
return_content: yes
follow_redirects: yes
register: restdata
curl -k -H "Content-Type: application/json" -X POST -d '{"username": "gorohov_da", "password": "qweASDzxc1!"}' https://10.100.205.65/api/v1/ticket
command: curl -k -H "Content-Type: application/json" -X POST -d '{"username": "gorohov_da", "password": "qweASDzxc1!"}' https://10.100.205.65/api/v1/ticket
register: data
curlcommand: 'curl -k -H -X POST -d ''{"username":"gorohov_da", "password":"qweASDzxc1!"}'' "https://10.100.205.65/api/v1/ticket"'
#ISE
curl -k --user apirest:restapi01 https://172.17.4.55/admin/API/mnt/Session/MACAddress/2C-0E-3D-3A-F4-E3
curl -k --user apirest:restapi01 https://172.17.4.55/admin/API/mnt/Session/MACAddress/70:56:81:4D:75:B0 | grep -P '([\w\.-]+)_([\w\.-]+)+(?=:)' -o
curl -k --user apirest:restapi01 https://172.17.4.55/admin/API/mnt/Session/MACAddress/70:56:81:4D:75:B0 | grep -P '([\w\.-]+)_([\w\.-]+)+(?=<)' -o
#!/bin/bash
echo enter MAC Address:
read input
mac=${input}
s="$(curl -s -k --user apirest:restapi01 https://172.17.4.55/admin/API/mnt/Session/MACAddress/$mac | grep -P '([\w\.-]+)_([\w\.-]+)+(?=<)' -o)"
echo $s
Last updated
Was this helpful?