Invoke GHRestMethod - X-Guardian/PowerShellForGitHub GitHub Wiki
A wrapper around Invoke-WebRequest that understands the Store API.
Invoke-GHRestMethod [-UriFragment] <String> [-Method] <String> [[-Description] <String>] [[-Body] <String>]
[[-AcceptHeader] <String>] [-ExtendedResult] [[-AccessToken] <String>] [[-TelemetryEventName] <String>]
[[-TelemetryProperties] <Hashtable>] [[-TelemetryExceptionBucket] <String>] [-NoStatus] [-WhatIf] [-Confirm]
[<CommonParameters>]
A very heavy wrapper around Invoke-WebRequest that understands the Store 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: 6
Default value: None
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
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
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
Deprecated switch after v0.14.0. Kept here for the time being to reduce module churn. Specifying it does nothing. It used to control whether or not the web request would have a corresponding progress UI.
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: 7
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: 9
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: 8
Default value: @{}
Accept pipeline input: False
Accept wildcard characters: False
The unique, tail-end, of the REST URI that indicates what Store 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
Prompts you for confirmation before running the cmdlet.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
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.