SQL and REST API

I built a dashboard a while back using Universal Dashboard and I’m attempting to replicated in Powershell Universal but not getting any results.

This is what it looked like in Universal Dashboard.

import-module UniversalDashboard

$SQLQueries = . (Join-Path $PSScriptRoot “\SQLQueries.ps1”)

$TransactionLookUp = New-UDEndpoint -Url ‘TransLookUp/:UniqueID’ -Endpoint{
param($UniqueID)

$Cache:TransactionsData | Where-Object UniqueIDCopy -EQ $UniquetID | ConvertTo-Json

}

Start-UDRestApi -Endpoint $TransactionLookUp -Port 10001 -Force

Running Invoke-Restmethod http://localhost:10001/api/TransLookUp/305 Would display the right results.

To replicate this behavior I tried going to http://localhost:5000/admin/ and adding a new endpoint /TransLookUp/:BudgetID. Below is what the endpoint looked like in the first attempt.

.“C:\ProgramData\UniversalAutomation\Repository\Dashboard\SQLQueries.ps1”

New-PSUEndpoint -Url “/TransLookUp/:UniqueID” -Endpoint {
param($UniqueID)

$Cache:TransactionsData | Where-Object UniqueIDCopy -EQ $UniquetID | ConvertTo-Json

}

No results were shown when running Invoke-RestMethod -Uri "http://localhost:5000/TransLookUp/305" -Method GET

Then I thought that maybe it wasn’t reading the file I referenced so I wrote the SQL queries within the endpoint but I still just got []

And yes, I know for a fact that $Cache:TransactionsData is not empty because I use that same data to produce a chart.

The cache is currently not available in APIs in Universal. It’s something we are looking at implementing in 1.5.

Thank you for the response. I understand that it’s still in development but will there be documentation on how to use SQL queries in APIS? Or will it most likely be almost the same as the first example?

I can provide a SQL example if that is helpful.

I would really appreciate that, thank you!

I’m just checking to see if this is now supported?

It’s been implemented in 1.5 (due out next week) and is documented here: https://docs.ironmansoftware.com/platform/cache

Perfect! Thank you so much!

I posted these 2 threads about a week ago but havent received any responses and I havent been able to figure them out either. Any chance you can take a look? Thank you again for all your help.

Multiple Datasets - Select Label

Data Types (Custom Formats) in Charts and Tables

Yep. I will follow up with those in a few.