# Return alarm status via web dev module

**URL:** <https://forum.inductiveautomation.com/t/return-alarm-status-via-web-dev-module/12652>\
**Category:** Ignition\
**Created:** [February 7, 2017, 6:19pm UTC](https://forum.inductiveautomation.com/t/return-alarm-status-via-web-dev-module/12652 "2017-02-07T18:19:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adolfo.rafael.martin](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@adolfo.rafael.martin](https://forum.inductiveautomation.com/u/adolfo.rafael.martin)\
**Post date:** [February 7, 2017, 6:19pm UTC](https://forum.inductiveautomation.com/t/return-alarm-status-via-web-dev-module/12652/1 "2017-02-07T18:19:09Z")

</div>

(I couldn’t find a question like this one even though it’s hard to imagine it hadn’t been already asked).

I’d like to respond with the output of alarm.queryStatus when a request with a GET verb is made.

But, the script

```
    alarmDict = system.alarm.queryStatus(source=["*HiAlarm*"])
jsonString = system.util.jsonEncode(alarmDict)
return {'html': '<html><body>" + jsonString + "</body></html>'}

```

produces

```
Traceback (most recent call last):

```

File “\<project32/alarms:doGet\>”, line 4, in doGet  
TypeError: cannot concatenate ‘str’ and ‘NoneType’ objects

Is there a better approach?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [February 7, 2017, 7:01pm UTC](https://forum.inductiveautomation.com/t/return-alarm-status-via-web-dev-module/12652/2 "2017-02-07T19:01:49Z")

</div>

Assuming alarmDict (and therefore jsonString) are valid variables, if you directly copy and pasted your code you’re using incompatible string delimiters:

return {‘html’: [size=200]’[/size][size=200]"[/size] + jsonString + [size=200]"[/size][size=200]’[/size]}

Try matching up the single quotes and double quotes:  
return {‘html’: [size=200]’[/size][size=200]’[/size] + jsonString + [size=200]’[/size][size=200]’[/size]}

You could also use [system.util.getLogger()](https://docs.inductiveautomation.com/display/DOC79/system.util.getLogger) to print those variables to the gateway console to ensure they’re valid.

---

<div class="post-metadata">

**Author:** ![adam.morales](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/adam.morales/32/3405_2.png) [@adam.morales](https://forum.inductiveautomation.com/u/adam.morales)\
**Post date:** [February 7, 2017, 10:53pm UTC](https://forum.inductiveautomation.com/t/return-alarm-status-via-web-dev-module/12652/3 "2017-02-07T22:53:03Z")

</div>

The problem here is that the jsonEncode() function does not seem to accept the “list” object produced by the queryStatus() function, so the jsonString variable never points to anything other than a NoneType. We can convert this to a Python list of alarm event objects using syntax like:

alarmDict = [x for x in system.alarm.queryStatus(source=[“_HiAlarm_”])]

However, a list of objects like this will cause the jsonEncode function to reach max recursion depth very quickly.

I think that the easiest solution is to convert this data to a PyDataset before encoding to Json. This would look something like this:

alarmDict = system.dataset.toPyDataSet(system.alarm.queryStatus(source=[“_HiAlarm_”]).getDataset())  
jsonString = system.util.jsonEncode(alarmDict)  
return {“response”:jsonString, “contentType”:“application/json”}

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [November 9, 2017, 9:10pm UTC](https://forum.inductiveautomation.com/t/return-alarm-status-via-web-dev-module/12652/4 "2017-11-09T21:10:02Z")

</div>

I currently am trying to use system.util.jsonEncode() for a large dict and getting the max recursion depth error.  
What can i do to prevent this? I need the large dict size for doing http POST requests.
