ONTAP Rest API Discussions

Getting 400 error code while trying to create volume using REST APIs

Juluri

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

1 ACCEPTED SOLUTION

Twesha

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

 

View solution in original post

2 REPLIES 2

Twesha

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

 

View solution in original post

Juluri

Hi Twesha,

 

Thank you very much for correcting the usage syntax, it worked fine

Also thanks for sharing info on netapp ontap package.

 

 

Announcements
NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner
Public