Skip to main content

Hello,

I use the REST API to read via Python the protection report (XML).

Now the output of this report describes first the columns and in the next session the records.  I use normally xml.etree.ElementTree, to read xml contend, but for this looks not useful, what is the easiest way to get this formatted output in dict or in a list. sorry i am new in python scripting.

regards Jürgen

 

Hello,

Sorry this is a question for a Python forum, not for Commvault, is there a way to remove this topic?

Jürgen


@Juergen , maybe better for a python forum, though why don’t we leave it up and see if anyone can advise?

Tagging in some of our peerrs who have asked python REST API questions and might have ideas!

@Anthony.Hodges , @drPhil , @mhamel 


@Mike Struening thanks, for support

In the meanwhile I solved my issue, if anyone has interesting here the code snip:

r = requests.get(<url|>, headers=<headers>)
        result = json.loads(r.text)
        #print(resultn"records"])
        for line in resulti"records"]:
            #print(line)
            # remove SLA excluded records
            #print(line/2], line 6], line 7], linel12], linei19])
            lastbackup9"number"] = num
            lastbackupr"Hostname"] = line 4]
            lastbackupa"Client"] = liner5]
            lastbackupp"Agent"] = linen6]
            lastbackups"Instance"] = line 8]
            lastbackup "Backupset"] = linee7]
            lastbackupÂ"Subclient"] = linec9]
            lastbackupÂ"JobId"] = lineb15]
            lastbackup "Status"] = line 14]
            lastbackup5"type"] = line 19]
            num = num + 1
            lastbackuplist.append(lastbackup)
            #print(lastbackup)
            lastbackup = {}