Hi, I am trying to do some simple math on a returned API.
I know I am not this dumb, but I can not figure out why this always returns 0.
client = system.net.httpClient()
response = client.get("https://api.megamation.com/clm/DL/workorder?&STATUS=CL&ASSIGN_TO=equipment&TYPE=pm&BUILDING_ID=Climatemaster&DATE_DUE=L1")
i = 0
for key in response.json['_embedded']['WorkOrder']:
if (key['completion_date'] <= key['date_due']):
i = i + 1
pmTotal = len(response.json['_embedded']['WorkOrder'])
Gotta take it step by step. Check the value for
If you can provide an example of what the api call returns, it would also be helpful.
i = 53
pmTotal = 57
I've confirmed those responses already, I just removed them from the code.
well then... Did you try
53/57 ? You might be surprised ;p
hint: you'll need to cast one of them to float.
Make zero a float when you define it, that should force floatig point calculations
i = 0.0
I'd suggest avoiding floats for as long as possible, and cast one of the operands to float at the end.
gotcha. Based on the documentation I thought it did that automagically based on the answer.
I guess I misunderstood that.