I'm trying to create a REST API dataset to return the alarms opened in the last X seconds. This X should be a parameter defined by the dataset consumer upon request.
In the "\Prognosis\WebUI\IIS\Administration\Config\RestApiDataSets.xml" file, I've added the following code. The forum automatically gets rid of XML tags so I had to cheat. Same thing for the "greater than or equal to" part, the original code is "& gt;", if I don't use a space or replace the & sign the forum would replace the character with a ">", which AFAIK cannot be used in the RestAPI file.
«dataSet» «id»getCustomerProbsum2«/id» «query»SELECT * FROM ProbSum WHERE OpenTime $gt;== Now() - @LookBackSeconds SECONDS NODE ALL ORDER BY opentime DESC, problemnumber ASC«/query» «/dataSet»
The issue is, it's not working, I get the following error : "Failed to get response from PQL: Syntax error near 'SECONDS'. Token: SECONDS." when accessing the following URL: /Prognosis/rest/v1/data/getCustomerProbsum2?LookBackSeconds=300
If I hardcode a value instead of the @LookBackSeconds parameter, the dataset works properly.
I can confirm that it seems like a bug or unsupported feature. I'll reach out to R&D and get a confirmation.
In the meanwhile, another way to approach the same problem is that you create a base view that also calculates 'ElapsedSeconds' for you. Then in your rest view, you can use that field as a regular field, instead of doing time manipulation.
C:\Prognosis\Server\Configuration>..\irpqlcli "Create View MyProblems as Select *, DateDiff(Second, OpenTime, Now()) as ElapsedSeconds FROM PROBSUMC"