Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Getting 400 error code while trying to create volume using REST APIs
2020-08-23
05:20 AM
3,163 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to create volume using REST APIs however its failing with 400 error code.
Here is the syntax I have used
data = {svm.name: svmname, name: volname, aggregates.name: aggrname}
newHeaders = {'accept': 'application/json', 'Content-type': 'application/json'}
response1 = requests.post("https://<clus-lif>/api/storage/volumes", json=data, auth=('xxxx', 'xxxx'), verify=False, headers=newHeaders)
print(response1.status_code)
svmname,aggrname,volname are parameters passed through script.
All the mandatory values are passed for volume creation not sure why its giving 400 error code.
Could you advise if any additional values or any modification needed to this code.
Thanks,
-Srini
Solved! See The Solution
1 ACCEPTED SOLUTION
Juluri has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Srini,
You need to specify the aggregates.name field as a list. So, the body would look like:
data = {"svm.name": svmname, "name": volname, "aggregates.name": [aggrname]}
Also, I would recommend taking a look at the netapp_ontap module. It is really nice and easy to use for scripting. You can find all the relevant links here: https://pypi.org/project/netapp-ontap/
-Twesha
2 REPLIES 2
Juluri has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Srini,
You need to specify the aggregates.name field as a list. So, the body would look like:
data = {"svm.name": svmname, "name": volname, "aggregates.name": [aggrname]}
Also, I would recommend taking a look at the netapp_ontap module. It is really nice and easy to use for scripting. You can find all the relevant links here: https://pypi.org/project/netapp-ontap/
-Twesha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Twesha,
Thank you very much for correcting the usage syntax, it worked fine
Also thanks for sharing info on netapp ontap package.
