Redirect Issues for APIs

I’m unable to make Invoke-UDRedirect work inside an API. I envisioned using it to redirect to a specific page on another website:

$Tickets = New-UDEndpoint -Url “/Ticket/:TicketID” -Method “GET” -Endpoint {
param($TicketID)
Invoke-UDRedirect -Url “https://example.com/ticket/$TicketID

The result only shows this:

Any advice?

hey @ncstalli

Try:

$Tickets = New-UDEndpoint -Endpoint {
                            Invoke-UDRedirect -Url "/Ticket/$($ArgumentList[0])" } -ArgumentList @($TicketID)

I believe that that should work.

In my own code, I have a foreach loop that creates a UDcard for each $item and I have a button that when you click it, it takes you to that specific card’s url. Adam and @AlonGvili helped me with this. Here is an excerpt of my code just to give you an idea:

New-UDButton -Icon plus -Floating -IconAlignment right -OnClick (New-UDEndpoint -Endpoint {                                                                 
                                Invoke-UDRedirect -Url  "/VA/$($ArgumentList[0])"                                 
                                                                     } -ArgumentList @($item.Indexname)) 

Hope that helps