ONTAP Rest API Discussions

Highlighted

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

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

2 REPLIES 2

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

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

Highlighted

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

Hi Twesha,

 

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

Also thanks for sharing info on netapp ontap package.

 

 

Check out the KB!
Knowledge Base
All Community Forums