Questions tagged [invoke-webrequest]
256 questions
9
votes
1 answer
Invoke-RestMethod hangs on long running endpoints
We are using Invoke-RestMethod in a PowerShell script to call a GET method endpoint with a variable length runtime. Some calls may return after a couple of seconds, some may take up to 20 minutes. We've set a 50 minute timeout on the call via the…

Ryan B
- 848
- 6
- 9
9
votes
2 answers
How to get StatusCode from request in PowerShell
I need to get success and/or error status code from a request using power shell. And i'm always getting a blank status.
I have tried with Invoke-WebRequest and Invoke-RestMethod.
I have sucess on the call but can't find a way of getting the status…

AndreG
- 113
- 1
- 1
- 7
8
votes
2 answers
Invoke-WebRequest without OutFile?
I used Invoke-WebRequest in Powershell to download a file without using the -OutFile parameter, and, from the documentation here, the file should've ended up in the directory I was in. However, there is nothing. Response was OK, no error was…

DMX David Cardinal
- 599
- 2
- 7
- 19
8
votes
1 answer
curl --data-binary in PowerShell
If I have a curl command such as:
curl \
-H 'Content-Type: application/json' \
-H 'API-Key: ' \
--data-binary '{"blah":"blah {\n blah2(accountId: id, integrations: {int1: {Vms: [{Id: id2, resourceGroups: [\"test1\", \"test2\",…

nobrac
- 372
- 1
- 6
- 16
5
votes
2 answers
Can I upload a file to onedrive via Windows 10 command line?
I need to upload a file to OneDrive, via the command line. This will be done through a batch file which is distributed to end users.
From searching on Stack Overflow, I find questions like this one which say that you need to register an app and…

Ne Mo
- 198
- 4
- 18
5
votes
1 answer
How to send Invoke-WebRequest with JSON body containing data from File
QUESTION:
How do I put a file's contents within the JSON body of an Invoke-WebRequest without the unneeded file metadata?
My goal is to send an HTTP request like so:
Invoke-WebRequest -Uri http://localhost:4321/updatefile `
-ContentType…

libzz
- 589
- 2
- 10
- 29
4
votes
0 answers
Invoke-WebRequest Error: An unexpected error occurred on a send
When I run the following command using cURL.exe to upload a file, I have no issues:
Curl.exe -X POST -H "X-API-TOKEN: token here" -F file=@"E:\program files\curl\filetoupload.csv"
https://url.com/files
I need to run it from a script so I thought I…

user2073183
- 141
- 1
- 3
- 13
4
votes
1 answer
How to sign into a website using the new param -form in pwsh
PowerShell 6.2.1 doesn't return a Forms property using Invoke-WebRequest. The way I used to do it in Powershell 5:
$r = Invoke-WebRequest -Uri 'somewebsite.com' -SessionVariable f
$f
$form = $r.Forms[0]
$form.Fields["userName"] =…

Drewtang
- 99
- 8
4
votes
1 answer
Invoke-WebRequest freezes / hangs
Why does the cmdlet "Invoke-WebRequest" freezes / hangs on certains URLs? Any workaround possible? I want to access the "span" objects for a given webpage and this cmdlet would be very useful if it didn't hang like that.
For example, this…

Rakha
- 1,874
- 3
- 26
- 60
4
votes
2 answers
Invoke-WebRequest is not recognized as the name of a cmdlet Windows 7 Powershell
How can I use this script on Windows 7 PowerShell?
$IE = new-object -com internetexplorer.application
$go = (Invoke-WebRequest –Uri ‘c:\link.html’).Links.href
$IE.navigate($go)
$IE.visible=$true
start-sleep 5
$word=$go = (Invoke-WebRequest –Uri…

mo.khorami
- 79
- 1
- 1
- 7
4
votes
3 answers
Powershell ConvertFrom-Json Encoding Special Characters Issue
I have this code in my powershell script and it doesn't do well on the special characters parts.
$request = 'http://151.80.109.18:8082/vrageremote/v1/session/players'
$a = Invoke-WebRequest -ContentType "application/json; charset=utf-8" $request…

user1425462
- 57
- 2
- 2
- 6
3
votes
1 answer
PowerShell, Download from OneDrive (*not* Business)
Programmatically downloading from Dropbox with PowerShell is trivial. With a link to a shared file https://www.dropbox.com/s/sdfjjthwrf32yFileName.pdf?dl=0, you just replace www.dropbox.com by dl.dropboxusercontent.com to give…

YorSubs
- 3,194
- 7
- 37
- 60
3
votes
1 answer
Trying to login into facebook with Powershell 6
I got to the point of logging in, but I get "Your request couldn't be processed" from facebook at the last step.
# Setup
#[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
$ProgressPreference =…

Eduard G
- 443
- 5
- 21
3
votes
1 answer
Cant' Access API with Powershell but can access using Postman, Python, or cURL
I'm trying to get data back from an API online using Powershell with the command Invoke-WebRequest -UseBasicParsing $request_string -Method Get -Headers $headers) but am getting back Invoke-WebRequest : The remote server returned an error: (403)…

Python Developer
- 551
- 1
- 8
- 18
3
votes
2 answers
When using Invoke-WebRequest Why can I only connect to certain URLs if I use UseBasicParsing?
I am iterating through a CSV file of URLs and using Invoke-WebRequest to get back the innerHTML and href values for links that match a specified criteria however this only works for some URLs and not for others unless I add the parameter…

Fearless_Shultz
- 71
- 5