Code Samples : cURL Code
  
cURL Code
Zerto recommends using cURL for scripting and testing before using another language, such as Python, for production. To use cURL with the Zerto Virtual Replication APIs, you must install cURL with SSL, for example from http://curl.haxx.se/download.html.
Note:  
You can turn off verification of the certificate by using the -k option in each cURL command.
Any content type included as part of the request is JSON format, -H "Content-Type: application/json".
The response returned in all the examples is JSON format, -H "Accept: application/json".
The following code shows how to start a session using cURL, where the response is headers.
curl -D responseHeader -H "Content-Type: application/json" -H "Accept: application/json" --user user:password https://zvm_ip:9669/v1/session/add -d "{\"AuthenticationMethod\":1}"
In this example, the VMware vCenter Server or Microsoft SCVMM hypervisor management tool credentials are used for authentication, -d "{\"AuthenticationMethod\":1}". To use Windows authentication, use -d "{\"AuthenticationMethod\":0}".
The responseHeader file that is returned is similar to the following:
HTTP/1.1 200 OK
Content-Length: 0
Server: Microsoft-HTTPAPI/2.0
x-zerto-session: 9UDQD6RG7YF33QJLWQXGJV8C453N277NA22P7FSNWVZCJTWCBRHQ
Date: Mon, 29 Jun 2015 07:57:49 GMT
The x-zerto-session value is used in all subsequent calls, such as in the following example the retrieve information about all the VPGs.
curl -D responseHeader -H "Content-Type: application/json" -H "Accept: application/json" -H "x-zerto-session: 9UDQD6RG7YF33QJLWQXGJV8C453N277NA22P7FSNWVZCJTWCBRHQ" https://zvm_ip:9669/v1/vpgs
The response to this command is the list of VPGs with information about each VPG, in Json format.
You can use filters with the VPG API, as in the following example, where only information about VPGs with a low priority (priority=0) are returned.
curl -D responseHeader -H "Content-Type: application/json" -H "Accept: application/json" -H "x-zerto-session: 9UDQD6RG7YF33QJLWQXGJV8C453N277NA22P7FSNWVZCJTWCBRHQ" https://zvm_ip:9669/v1/vpgs?priority=0
To perform an action on a VPG, such as a failover test using a specific checkpoint, use a cURL command similar to the following.
curl -D responseHeader -H "Content-Type: application/json" -H "Accept: application/json" -H "x-zerto-session: 9UDQD6RG7YF33QJLWQXGJV8C453N277NA22P7FSNWVZCJTWCBRHQ" https://zvm_ip:9669/v1/vpgs/a8c3d56d-1289-48ba-a054-72447ee73821/failover -d "{\"CheckpointId\":2419}"
The response is the task identifier or an error message if the action fails.