ONTAP Rest API Discussions

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

Juluri
2,133 Views

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
2,077 Views

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
2,078 Views

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

 

Juluri
2,021 Views

Hi Twesha,

 

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

Also thanks for sharing info on netapp ontap package.

 

 

Public