Create Protection Domain Schedule via API/Python

  • 6 February 2019
  • 1 reply


I'm trying to create a schedule for an existing Protection Domain like this:

def createProtectionDomainSchedule(self,pdname):
# Set the schedule for the protection domain
policy = {"retention_policy": {"remote_retention_type": None, "remote_max_snapshots": {}, "local_retention_period": None, "local_max_snapshots": 1, "remote_retention_period": {}, "local_retention_type": None}, "start_times_in_usecs": [1549477620000000L], "rollup_schedule_uuid": None, "user_start_time_in_usecs": 1549477620000000L, "is_rollup_sched": None, "pd_name": pdname, "values": None, "suspended": False, "app_consistent": False, "end_time_in_usecs": None, "type": "DAILY", "id": "63c037e5-41e4-4630-8641-23509a5360a1gg", "every_nth": 1}

protectionDomainURL = self.base_url + "/protection_domains/"+pdname+"/schedules"

serverResponse =, policy )
print serverResponse.text
return json.loads(serverResponse.text)
except Exception as e:

However, this returns:

{"message":"Unexpected character ('r' (code 114)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')","detailed_message":" Unexpected character ('r' (code 114)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n\tat com.nutanix.prism.web.providers.ProtobufJsonProvider.getInputObject(\n\tat

I'm wondering if someone has a working example to do this?



Best answer by Chandru 8 February 2019, 21:55

View original

This topic has been closed for comments

1 reply

Userlevel 3
Badge +13
@Michelp_be One issue i see in your code is that the last two characters in the id contains letter `g` any UUID only contains characters a to f. But this doesn't seem to be causing the error and yoou can ignore the id altogether it will still update.

The error may be caused by the payload getting passed in non-json format. This could be because you are not setting header "content-type:application/json" or the data payload is being converted to string instead of being passed as dictionary.

I tried your payload exactly and i'm able to successfully create the schedule