- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2018 08:04 PM - edited 03-01-2019 05:29 AM
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.
Solved! Go to Solution.
- Labels:
-
Cisco ACI
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2018 08:46 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2018 08:46 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2018 10:34 PM
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.
