Attemping to store API values in tag

I wanted to add that I was able to clean this up and store the data in a tag as a dataset instead of a string array as above, which will link to a perspective table directly.

def getPMList(building):
	client = system.net.httpClient()
	response = client.get("https://api.megamation.com/clm/DL/workorder?STATUS=S&TYPE=PM&BUILDING_ID="+building, username="<>", password="<>")
	data = []
	for key in response.json['_embedded']['WorkOrder']:
		data.append([key['wo_no'], key['date'], key['building_id'], key['work_request_description']])

	
	headers = ['wo_no', 'date', 'building_id', 'work_request_description']	
	listing = system.dataset.toDataSet(headers, data)
	system.tag.writeAsync(["maintenance/megamation/number_open_pms","maintenance/megamation/pmList"], [len(data), listing])
1 Like