Skip to content

Conversation

@vercellone
Copy link
Contributor

@vercellone vercellone commented Feb 2, 2025

Description

Invoke-GitHubRestMethod

  • Calls Invoke-RestMethod instead of Invoke-WebRequest
  • SupportsPaging (First and Skip, but not IncludeTotal)
  • Added a $GITHUB_RESPONSES global variable to store a collection of (Content, Date, Headers, StatusCode, and Uri) objects, because attempts to set a variable in the parent scope failed. I added an HttpResponsesVariable property to the config, so someone can opt for a different global variable name as a matter of preference or necessity in the event of a conflict.
  • Parameters are compatible with Invoke-GitHubAPI except for Accept, which should be specified via a Headers.

New .PARAMETERs

  • Headers Specifies the headers of the web request. Enter a hash table or dictionary.
  • ExpandProperty If specified and the property exists in the web response, this property will be expanded priot to output.
  • MaximumRetryCount Specifies how many times PowerShell retries a connection when a failure code between 400 and 599, inclusive or 304 is received. Also see RetryIntervalSec parameter for specifying number of retries.
  • QueryParameters An IDictionary of query string parameters to add to the Uri via ConvertTo-QueryString.
  • RetryIntervalSec Specifies the interval between retries for the connection when a failure code between 400 and 599, inclusive or 304 is received. Also see MaximumRetryCount parameter for specifying number of retries. The value must be between 1 and [int]::MaxValue.

I reworked Get-GitHubUser using Invoke-GitHubRestMethod as a demonstration of the impact.

Type of change

  • 📖 [Docs]
  • 🪲 [Fix]
  • 🩹 [Patch]
  • ⚠️ [Security fix]
  • 🚀 [Feature]
  • 🌟 [Breaking change]

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas

@vercellone vercellone requested a review from a team as a code owner February 2, 2025 23:06
@MariusStorhaug MariusStorhaug changed the base branch from main to vercellone/RestMethod February 4, 2025 10:43
@MariusStorhaug MariusStorhaug merged commit 4f3f479 into PSModule:vercellone/RestMethod Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants