Wait for a WebRequest to complete

Hello Folks,

I’m trying to figure out a way to make the Dashboard show up a loading bar while waiting for a web request to complete. I haven’t been able to find a way to catch the Invoke-WebRequest execution status to show up a loading bar while the request is in progress. I have tried the Start-Job / Wait-Job solution, but it doesn’t seem to work as expected. When I query the web service it take roughly 20 sec to load and the Start-Job / Wait-Job takes roughly 2 seconds to give me a completed state which can’t be true.

I’d love some thought or ideas.

Many thanks in advance for your help !

dont this do what you want?

Hey @Speegel I recently created a bunch of cool spinners for UD so would be awesome for you to have a go at using one of those, you can choose from about 30 different spinners, set size and colour…anyway back to the question, I used the technique @mylabonline kindly shared, which inspired me to do the spinner thing, for a situation like yours:-

hey @psDevUK ! Thx for the proposal, I’ll give it a try :slight_smile:

I did found a solution that is doing what I was looking for.

First I build up a POST request, adding info to the body and so on.
Then I do the request on the REST API using POST Method which generate a GUID, Starting a powershell Job using that GUID and returning the GUID.
Finally I do a GET request with the GUID as parameter, that will query the powershell job “(Get-Job -Name $GUID).Status” and loop as long as the status ain’t “completed”. This solution avoid hanging the whole portal while the data is requested.

If you have any comment or advice regarding the solution feel free to let me know :smiley:

Cheers !

1 Like

I know this is a old thread, would it be possible to see an example of an implementation of this? I 've been struggling to implement jobs with a UDEndpoint api trigger.