r/PowerShell • • May 29 '26

Solved Invoke-WebRequest to call the reddit api suddenly broken

Been running a script forever without issue. You don't need OAuth2 to grab the last 100 comments of a user like this:

https://api.reddit.com/user/spez.json?limit=100&after=

or

https://www.reddit.com/user/spez.json?limit=100&after=

A few months ago I added the -UseBasicParsing tag.

Today I'm getting

+ CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

My line of code is $response = Invoke-WebRequest -UseBasicParsing $url | ConvertFrom-Json where $url looks like the https lines above.

Can anyone shed light, please? Thanks.

25 Upvotes

11 comments sorted by

View all comments

Show parent comment

0

u/[deleted] May 29 '26

[deleted] — view deleted comment

5

u/420GB May 29 '26

curl is, yes, that's why you have to use curl.exe which is the program. That's why I said curl.exe in my comment.

2

u/surfingoldelephant May 29 '26

In Windows PowerShell v5.1, yes. But it was removed as an alias in PS v6, so curl in the current PS v7 will call the external application (assuming it exists).

3

u/JazzGreenway May 29 '26

Yes but curl.exe is also included in Windows as a binary. You need to specify the .exe though.