-
Notifications
You must be signed in to change notification settings - Fork 190
Invoke GHRestMethod
A wrapper around Invoke-WebRequest that understands the GitHub API.
Invoke-GHRestMethod [-UriFragment] <String> [-Method] <String> [[-Description] <String>] [[-Body] <String>]
[[-AcceptHeader] <String>] [[-InFile] <String>] [[-ContentType] <String>] [[-AdditionalHeader] <Hashtable>]
[-ExtendedResult] [-Save] [[-AccessToken] <String>] [[-TelemetryEventName] <String>]
[[-TelemetryProperties] <Hashtable>] [[-TelemetryExceptionBucket] <String>] [<CommonParameters>]
A very heavy wrapper around Invoke-WebRequest that understands the GitHub API and how to perform its operation with and without console status updates. It also understands how to parse and handle errors from the REST calls.
The Git repo for this module can be found here: http://aka.ms/PowerShellForGitHub
Invoke-GHRestMethod -UriFragment "users/octocat" -Method Get -Description "Get information on the octocat user"
Gets the user information for Octocat.
Invoke-GHRestMethod -UriFragment "user" -Method Get -Description "Get current user"
Gets information about the current authenticated user.
Specify the media type in the Accept header. Different types of commands may require different media types.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: $script:defaultAcceptHeader
Accept pipeline input: False
Accept wildcard characters: False
If provided, this will be used as the AccessToken for authentication with the REST Api as opposed to requesting a new one.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 9
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Allows the caller to specify any number of additional headers that should be added to the request.
Type: System.Collections.Hashtable
Parameter Sets: (All)
Aliases:
Required: False
Position: 8
Default value: @{}
Accept pipeline input: False
Accept wildcard characters: False
This optional parameter forms the body of a PUT or POST request. It will be automatically encoded to UTF8 and sent as Content Type: "application/json; charset=UTF-8"
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies the value for the MIME Content-Type header of the request. This will usually be configured correctly automatically. You should only specify this under advanced situations (like if the extension of InFile is of a type unknown to this module).
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 7
Default value: $script:defaultJsonBodyContentType
Accept pipeline input: False
Accept wildcard characters: False
A friendly description of the operation being performed for logging and console display purposes.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
If specified, the result will be a PSObject that contains the normal result, along with the response code and other relevant header detail content.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Gets the content of the web request from the specified file. Only valid for POST requests.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 6
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The type of REST method being performed. This only supports a reduced set of the possible REST methods (delete, get, post, put).
Type: System.String
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
If specified, this will save the result to a temporary file and return the FileInfo of that temporary file.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
If provided, the successful execution of this REST command will be logged to telemetry using this event name.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 10
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
If provided, any exception that occurs will be logged to telemetry using this bucket. It's possible that users will wish to log exceptions but not success (by providing TelemetryEventName) if this is being executed as part of a larger scenario. If this isn't provided, but TelemetryEventName is provided, then TelemetryEventName will be used as the exception bucket value in the event of an exception. If neither is specified, no bucket value will be used.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 12
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
If provided, the successful execution of this REST command will be logged to telemetry with these additional properties. This will be silently ignored if TelemetryEventName is not provided as well.
Type: System.Collections.Hashtable
Parameter Sets: (All)
Aliases:
Required: False
Position: 11
Default value: @{}
Accept pipeline input: False
Accept wildcard characters: False
The unique, tail-end, of the REST URI that indicates what GitHub REST action will be performed. This should not start with a leading "/".
Type: System.String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
This wraps Invoke-WebRequest as opposed to Invoke-RestMethod because we want access to the headers that are returned in the response, and Invoke-RestMethod drops those headers.
[Back to PowerShellForGitHub]
- Add-GitHubAssignee
- Add-GitHubGistStar
- Add-GitHubIssueLabel
- Backup-GitHubConfiguration
- Clear-GitHubAuthentication
- ConvertFrom-GitHubMarkdown
- Copy-GitHubGist
- Disable-GitHubRepositorySecurityFix
- Disable-GitHubRepositoryVulnerabilityAlert
- Enable-GitHubRepositorySecurityFix
- Enable-GitHubRepositoryVulnerabilityAlert
- Get-GitHubAssignee
- Get-GitHubCloneTraffic
- Get-GitHubCodeOfConduct
- Get-GitHubConfiguration
- Get-GitHubContent
- Get-GitHubEmoji
- Get-GitHubEvent
- Get-GitHubGist
- Get-GitHubGistComment
- Get-GitHubGitIgnore
- Get-GitHubIssue
- Get-GitHubIssueComment
- Get-GitHubIssueTimeline
- Get-GitHubLabel
- Get-GitHubLicense
- Get-GitHubMilestone
- Get-GitHubOrganizationMember
- Get-GitHubPathTraffic
- Get-GitHubProject
- Get-GitHubProjectCard
- Get-GitHubProjectColumn
- Get-GitHubPullRequest
- Get-GitHubRateLimit
- Get-GitHubReaction
- Get-GitHubReferrerTraffic
- Get-GitHubRelease
- Get-GitHubReleaseAsset
- Get-GitHubRepository
- Get-GitHubRepositoryActionsPermission
- Get-GitHubRepositoryBranch
- Get-GitHubRepositoryBranchProtectionRule
- Get-GitHubRepositoryCollaborator
- Get-GitHubRepositoryContributor
- Get-GitHubRepositoryFork
- Get-GitHubRepositoryLanguage
- Get-GitHubRepositoryTag
- Get-GitHubRepositoryTeamPermission
- Get-GitHubRepositoryTopic
- Get-GitHubTeam
- Get-GitHubTeamMember
- Get-GitHubUser
- Get-GitHubUserContextualInformation
- Get-GitHubViewTraffic
- Group-GitHubIssue
- Group-GitHubPullRequest
- Initialize-GitHubLabel
- Invoke-GHRestMethod
- Invoke-GHRestMethodMultipleResult
- Join-GitHubUri
- Lock-GitHubIssue
- Move-GitHubProjectCard
- Move-GitHubProjectColumn
- Move-GitHubRepositoryOwnership
- New-GitHubGist
- New-GitHubGistComment
- New-GitHubIssue
- New-GitHubIssueComment
- New-GitHubLabel
- New-GitHubMilestone
- New-GitHubProject
- New-GitHubProjectCard
- New-GitHubProjectColumn
- New-GitHubPullRequest
- New-GitHubRelease
- New-GitHubReleaseAsset
- New-GitHubRepository
- New-GitHubRepositoryBranch
- New-GitHubRepositoryBranchProtectionRule
- New-GitHubRepositoryFork
- New-GitHubRepositoryFromTemplate
- New-GitHubTeam
- Remove-GitHubAssignee
- Remove-GitHubGist
- Remove-GitHubGistComment
- Remove-GitHubGistFile
- Remove-GitHubGistStar
- Remove-GitHubIssueComment
- Remove-GitHubIssueLabel
- Remove-GitHubLabel
- Remove-GitHubMilestone
- Remove-GitHubProject
- Remove-GitHubProjectCard
- Remove-GitHubProjectColumn
- Remove-GitHubReaction
- Remove-GitHubRelease
- Remove-GitHubReleaseAsset
- Remove-GitHubRepository
- Remove-GitHubRepositoryBranch
- Remove-GitHubRepositoryBranchProtectionRule
- Remove-GitHubRepositoryTeamPermission
- Remove-GitHubTeam
- Rename-GitHubGistFile
- Rename-GitHubRepository
- Rename-GitHubTeam
- Reset-GitHubConfiguration
- Restore-GitHubConfiguration
- Set-GitHubAuthentication
- Set-GitHubConfiguration
- Set-GitHubContent
- Set-GitHubGist
- Set-GitHubGistComment
- Set-GitHubGistFile
- Set-GitHubGistStar
- Set-GitHubIssue
- Set-GitHubIssueComment
- Set-GitHubIssueLabel
- Set-GitHubLabel
- Set-GitHubMilestone
- Set-GitHubProfile
- Set-GitHubProject
- Set-GitHubProjectCard
- Set-GitHubProjectColumn
- Set-GitHubReaction
- Set-GitHubRelease
- Set-GitHubReleaseAsset
- Set-GitHubRepository
- Set-GitHubRepositoryActionsPermission
- Set-GitHubRepositoryTeamPermission
- Set-GitHubRepositoryTopic
- Set-GitHubTeam
- Split-GitHubUri
- Test-GitHubAssignee
- Test-GitHubAuthenticationConfigured
- Test-GitHubGistStar
- Test-GitHubOrganizationMember
- Test-GitHubRepositoryVulnerabilityAlert
- Unlock-GitHubIssue