cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2352
Views
5
Helpful
2
Replies

Python request POST method with ACI

ITforever
Level 1
Level 1

Hello,

 

I am trying do something simple - just to create an object (tenant, ANP, EPG, etc.) using python requests. I am wondering what I do wrong:(

 

My GET requests are working fine.

 

Considering that I have already successful login/cookies, my code is as below:

======================================================================

pyTnData = {"fvTenant": {"attributes": {"name": "WXYZ"}}}
jsonTnData = json.dumps(pyTnData)
print(type(jsonTnData)) # comes as a string type

 

createTn = requests.post('http://10.11.12.13/api/class/fvTenant.json', cookies=cookies, json=jsonTnData, verify=False)

======================================================================

 

Thanks.

1 Accepted Solution

Accepted Solutions

stcorry
Cisco Employee
Cisco Employee
Hello!

The URL in your post is in the form of a class query. To post, you should post the object ( a tenant) to it's parent object which would be uni. So the path of the URL should be something like /api/mo/uni.json

View solution in original post

2 Replies 2

stcorry
Cisco Employee
Cisco Employee
Hello!

The URL in your post is in the form of a class query. To post, you should post the object ( a tenant) to it's parent object which would be uni. So the path of the URL should be something like /api/mo/uni.json

Thanks for your answer. Yes, it works now.

 

I corrected the url path to pint to  the parent object (uni) and also corrected the protocol to https. It was http before and didn't work with it.

Review Cisco Networking for a $25 gift card

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