UDTable not loading data

Hi everyone,

For some reason, when I created this new page to display a table with data collected from API response, it does not display anything. I’m using same code I have in the main page. The only thing different are variable naming, Id’s and API endpoint. Everything else is the same. Why it works in one page and not the other?

I can run this in terminal with no issues

Data is collected, processed, stored in PS datatable and displayed with UDTable. It should display 6 rows and 1 column for testing.

Table data for netinfracloud was null

New-UDDynamic -Id 'cloudpapercontent' -Content {
    $Global:cloudapidata = Invoke-WebRequest "API_ENDPOINT_HERE" -SkipCertificateCheck
    
    New-UDPaper -Elevation 0 -Content {
        New-UDTypography -Text "Last Refresh: $((Get-Date).DateTime)" -Variant body1
    }

    New-UDPaper -Elevation 1 -Content {
       # Code from below line all the way down to $CloudDataGrid works with no issues in terminal
        $clouddt = New-Object System.Data.DataTable
        $clouddt.Clear()
        $clouddt.Columns.Add("Device")

        $cloudsensors = $Global:cloudapidata.sensors | Where {$_.group -eq "Network Infrastructure"}
        foreach ($cloudsensorrow in $cloudsensors) {
            if (!($clouddt.Columns.Contains($cloudsensorrow.sensor))) {
                $clouddt.Columns.Add("$($cloudsensorrow.sensor)")
            }
        }

        foreach ($cloudsensor in $cloudsensors) {
            $clouddr = $clouddt.NewRow()
            $clouddr["Device"] = $cloudsensor.device

            $clouddevices = $Global:cloudapidata.sensors | Where {$_.group -eq "Network Infrastructure" -and $_.device -eq $cloudsensor.device}
            
            if (!($clouddt.Select("Device = '" + $cloudsensor.device + "'"))) {
                foreach ($clouddevice in $clouddevices) {
                    if($clouddevice.status -eq "Up")
                    {
                        $url = "http://localhost:5000/img/up.png"
                    }

                    if($clouddevice.status -eq "Down")
                    {
                        $url = "http://localhost:5000/img/down.png"
                    }

                    if($clouddevice.status -eq "Warning")
                    {
                        $url = 'http://localhost:5000/img/warning.png'
                    }

                    if($clouddevice.status -eq "Paused (paused)")
                    {
                        $url = "http://localhost:5000/img/pause.png"
                    }

                    if($clouddevice.status -eq "Unusual")
                    {
                        $url = "http://localhost:5000/img/unusual.png"
                    }

                    switch ($clouddevice.sensor)
                    {
                        "Ping"
                        {
                            $clouddr["Ping"] = $url
                            break
                        }
                        "DNS"
                        {
                            $clouddr["DNS"] = $url
                            break
                        }
                        "Http"
                        {
                            $clouddr["HTTP"] = $url
                            break
                        }
                        "RDP (Remote Desktop)"
                        {
                            $clouddr["RDP (Remote Desktop)"] = $url
                            break
                        }
                    }
                }
                $clouddt.Rows.Add($clouddr)
            }
        }
        # Fill empty cells with N/A png link
        for ($i = 0; $i -lt $clouddt.Rows.Count; $i++)
        {
            if ($clouddt.Rows[$i].Ping.ToString() -eq "")
            {
                $clouddt.Rows[$i].Ping = "http://localhost:5000/img/na.png"
            }
            if ($clouddt.Rows[$i].DNS.ToString() -eq "")
            {
                $clouddt.Rows[$i].DNS = "http://localhost:5000/img/na.png"
            }
            if ($clouddt.Rows[$i].HTTP.ToString() -eq "")
            {
                $clouddt.Rows[$i].HTTP = "http://localhost:5000/img/na.png"
            }
            if ($clouddt.Rows[$i].'RDP (Remote Desktop)'.ToString() -eq "")
            {
                $clouddt.Rows[$i].'RDP (Remote Desktop)' = "http://localhost:5000/img/na.png"
            }
        }
        # Here I'm only selecting Device column for testing UDTable
        $CloudDataGrid = $clouddt | Select-Object Device

        $CloudGridColumns = @(
            New-UDTableColumn -Property Device
        )

        New-UDTable -Id 'netinfracloud' -Data $CloudDataGrid -Columns $CloudGridColumns -Title 'Services' -ShowSearch -ShowPagination -PageSizeOption @(5,10,20)
    }
} -AutoRefresh -AutoRefreshInterval 30

Product: PowerShell Universal
Version: 1.5.8
Framework: Latest

Thanks for all of your help and advice

can look into the browser console and upload an image of the error if any ?

Good morning @AlonGvili

That never cross my mind to check. I will take a look later in the morning and report back.

Thanks

@AlonGvili

I see no errors in the browser console

@AlonGvili

I’m even trying with a smaller table; 6 rows with 3 columns, and still getting “Table data was null”

Am I missing something ?

i don’t see any columns to, can you use full UDColumn command ?

Good morning @AlonGvili

Issue was caused by my frustration. While I was showing my code to my boss, he asked me, show me from the begging and how to you get the data. So I started explaining and noticed that the API link was using the incorrect file format (XML) and my code is based on JSON return. Uhg… embarrassing and funny!!

I apologize for the time wasted, truly am.

it ok dude the most important thing is that everything is ok now :slight_smile: :metal: