API POST : Add VM to data protection

Badge +2
Hello, I'm beginner at Nx REST API.

I start with API GET to get value of cluster, it's no problem.

But now next project "Auto add VM to data protection script" with API POST, I can add vm to data protection by html REST API.

Next step, I want to run auto script. I have a code when I click "Try it out!"

{ "name": "DGT_name", "vms": [ { "vmHandle": xxxxx, "vmId": "xxxxx", "vmName": "VM_NAME1", "vmPowerStateOnRecovery": "Power state at time of snapshot", "consistencyGroup": "VM_NAME1", "appConsistentSnapshots": false, "vmRecoverability": [], "vmFiles": null, "relatedEntityUuids": [] } ], "nfsFiles": [], "volumeGroups": [], "vstoreId": null, "active": true, "remoteSiteNames": [], "cronSchedules": [], "minSnapshotToRetain": null, "nextSnapshotTimeUsecs": null, "pendingReplicationCount": 0, "ongoingReplicationCount": 0, "markedForRemoval": false, "hybridSchedulesCount": null, "metroAvail": null, "totalUserWrittenBytes": null, "replicationLinks": [], "syncReplications": null, "annotations": []}
I don't know how to use this code

Please give me "NX REST API using POST" example. (I'm very happy if you give me a data protection script haha)

Thank you very much.

Sorry for my poor english.

3 replies

Userlevel 4
Badge +19

You can refer the below code.

Badge +2
Thank you, I will learn it now!

.. I have some question, can this script write in python ?
Theres one that has been created before. : https://github.com/nutanix/Connection-viaREST/blob/master/api_python_authenticate_pd.py