Working with REST
A REST-compliant web service allows a client to interact with the service using a set of predefined stateless operations. REST is not a protocol; it is an architectural style.
Whether or not an interface is truly REST-compliant is not particularly relevant when the goal is to use one in PowerShell. Interfaces must be used according to any documentation that has been published.
Invoke-RestMethod
is the default command most often used when interacting with REST services. Invoke-RestMethod
automatically parses responses, typically JSON responses, into an object that can be directly used in PowerShell.
Invoke-RestMethod
is occasionally also useful if the content of a site is interesting. The command automatically expands content instead of returning information about the web request.
For example, Invoke-RestMethod
can be used to get the weather:
Invoke-RestMethod -Uri wttr.in
It can also be used with any service that returns JSON content, such...