Zerto 5.0 Update 3 API Changes

Posted by

Some users of Zerto may have seen an API change in 5.0 update 3 which related to a change in accept headers and content.

Essentially if you have been using Zerto provided scripts on previous versions of Zerto such as RPO reporting over time, recovery plans etc. Then you will have found when you run the script the result is null. This does relate to the scripts written by Zerto & Joshua Stenhouse whitepaper where he wrote a number of scripts on automating Zerto. Joshua’s blog can be founds HERE and is a great resource for scripting with Zerto, Rubik, CLI and PowerShell.  Note Josh has also posted and is amending scripts he built, see below for more details on that.

The change was down to security to ensure the API is as secure as possible from any  malicious efforts from HTML or JS.

So what has changed and what do you need to do to your existing scripts to get them working again? Thankfully the change is fairly simple:

We have to modify the session header so that it now includes the content type in the session, below is an old example:

pic 2
Original Zerto Session Header

With the new way we have to add the content-type argument in to the header, the default is now JSON so you may find in previous scripts where an XML is called then the value of that object or array comes back as NULL. The new headers to be inserted are below:

pic 3
New Zerto Session Header

So the next step is to call these headers during an “Invoke-RestMethod” to the API, see an example below:

pic 4
Example Invoke-RestMethod with new Header

Throughout many examples in Zerto’s scripts we typically call -ContentType from a set variable such as $json or $xml, the $zertoSessionHeader variable now needs to be adjusted to match the Zerto session headers as above along with altering the -ContentType argument.

Josh Stenhouse is working through the scripts he wrote and adjusting, this is mostly affecting XML throughout the scripts where it was beneficial to import / export data as XML (default now JSON). His blog again is here and I am sure he will post updated versions of his scripts. Again his blog link is HERE

Please feel free to reach out, I have adjusted a good number of scripts so far ensuring they work on 5.0 update 3. There will be a further field notice from Zerto on the changes along with the documentation being updated.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s