here is my code.
from xml.etree.ElementTree import Element, SubElement, Comment,XML
from schedularConf import EXECUTION_CONST
(Execution_Const is in different python script and here is the code.
import json
import xmltodict
import requests
from xml.etree import ElementTree
from string import Template
class EXECUTION_CONST():
# Header for HTTP request.
headers = {'Content-Type': 'application/xml'}
# Availability Tests
SCHEDULAR_LISTS = {
" Availability Test": "https://servername/vco/api/workflows/workflowID"
})
class schedule:
def getData(self):
try:
list = EXECUTION_CONST.SCHEDULAR_LISTS;
for name, url in list.iteritems():
mainUrl = url.split("workflows")[0]+"/tasks";
nameSch = name.split("-")[1];
# print (nameSch)
list = requests.get(mainUrl,auth = ('username', 'password'),verify=False).text
print (list)
lists = json.dumps(list)
#print (lists)
# for l in lists:
# if l == " Availability Test":
# print(" Availability Test is available" )
# else:
# print ("Availability Test is not available")
# XML = '<task xmlns="http://www.vmware.com/vco"><name>'+nameSch+'</name><recurrence-cycle>one-time</recurrence-cycle><recurrence-start-date>2017-09-30T11:52:00+03:00</recurrence-start-date><workflow href="'+url+'"></workflow><start-mode>normal</start-mode></task>'
#
# print (XML)
# res = requests.post(mainUrl,data=XML,headers=EXECUTION_CONST.headers,
# auth = ('username', 'password'),verify=False).text
# print (res);
except Exception, e:
print e
return ;