REST

ASA- https://www.cisco.com/c/en/us/td/docs/security/asa/api/qsg-asa-api.html

Representational state transfer. Representational speaking on behalf of someone like the computer and can transfer the information with status. Basically the requesting, processing and responding.

Crud: Create(POST can create object or resource), Read(GET reads data), Update(Put, Patch), Delete(Delete). Patch might be a very minor change where PUT may be a major change.  POST, PUT, and PATCH requests typically include data and also usually require authentication along with DELETE also requiring authentication. Get requests typically include data coming back.

Rest methods:

Rest-methods

Status codes: 200 ,all ok. 404, which I’m sure we have all came across-> resource not found. 201, Created, new resource created. 400, Bad Request, request invalid. 401, Unauthorized, Authentication missing or incorrect. 403, Forbidden, Request was understood, but not allowed. 500, Internal Server Error, Something went wrong with server. 503, Service unavailable, Server is unable to complete request.

Headers: provide details and meta-data. Content-type would specify the format of the data in the body. Access would specify the requested format for return data. Authorization allows you to provide credentials. Date provides date and time for request.

Authentication:

Basic- username and password in encoded string. Not encrypted, base64. Easy to reverse. Is secure if the server is https.

Token- a secret generally derived from API developer portal. May be called ticket or secure key. This token is added to the headers.

OAuth- Standard framework for a flow to retrieve an access token. Request for Token.

Tokens are usually short lived. Only good for maybe 5 minutes and then have to be refreshed.

Basic request:

Curl-restapi-request-chuck-norris

API delivers a random joke.

Adding options to our request.

Curl-restapi-request-chuck-norris-2-options

curl -v; for verbose if you want to see all the header data. “>” indicates request | “<” indicated response. “<” pointing and sending to me. “>” pointing away my system is sending stuff out.

curl -vk \  end of line continuation and k is accepting self signed cert by router.

>-u myroot:mysecretpass \

>-H “accept: application/yang-data+json” \

>https://10.10.20.21/restconf/data/interfaces/interface=GigabitEthernet2

enter after the last line prints out our interface information

Leave a comment