Context:
- You can call API of web services (e.g. GitHub) with Invoke-RestMethod.
- GitHub pagination API contains the last page number in HTTP responce headers.
Problem:
You can’t access HTTP responce headers with Invoke-RestMethod or the return value of it.
Reason:
It is by design. Invoke-RestMethod doesn’t have interfaces to access to HTTP responce headers.
Solution:
The return value of Invoke-WebRequest has interface to HTTP responce headers. You can use Invoke-WebRequest with ConvertFrom-Json instead of Invoke-RestMethod.