cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
354
Views
0
Helpful
1
Replies

Passing APIC-Cookie on subsequent API calls using requests in Python

sdavids5670
Level 2
Level 2

I'm trying to write a python script that will help me with a project that I'm working on and I'm confused about what to do after I've logged into the APIC (stored my APIC-Cookie that I get in the initial login prompt).  On subsequent requests, using the requests module, how do I include the session cookie?  Do I format that in JSON and pass it as payload?  Do I put it somewhere in a header?

What would a subsequent request look like (for instance, if I wanted to return all of the interfaces - operational status, description, epgs, etc - from a specific leaf).

1 Reply 1

Remi-Astruc
Cisco Employee
Cisco Employee

Hi @sdavids5670 ,

If you previously stored the cookie in APIC-Cookie, pass it as argument in the "get" function for subsequent requests, like that:

your_response = your_session.get('https://apic/api/class/l1Physif.json', cookies=APIC-Cookie, verify=False)

Regards

Remi Astruc

Review Cisco Networking for a $25 gift card

Save 25% on Day-2 Operations Add-On License