Downloading a file with a parameter endpoint

Is it possible to pass a parameter to an endpoint for downloading files, so that we know exactly the file name?

Invoke-RestMethod “http://:5000$ip/utils/$name” -outfile “somename.exe”

as per:

Using a parameter I get this error
Invoke-RestMethod : Unable to read data from the transport connection: An existing connection was forcibly closed by
the remote host.

If I adhere to the docs (no parameter) I am able to download the executable.
More of a feature request I suppose.

BTW, I input the variable in front

How have you defined your endpoint? This would work as long as your endpoint is expecting a parameter there.

The URL for example would be: http//localhost:5000/utils/:name

Yes, exactly. Likely elsewhere, not in PS Universal.
So it seems to work fine when I make the call from pwsh core, and it fails in windows powershell. The latter case - the download starts and depending on the exact utility (these are executables) it stops with
Invoke-RestMethod : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
Thanks