Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Invoke-RestMethod doesn't return useful info when no data is returned. #5320

Copy link
Copy link
@thezim

Description

@thezim
Issue body actions

Steps to reproduce

You will need to generate an API token and grant the notifications privilege.

PS /Users/greg> $apitoken = "yourapitoken"
PS /Users/greg> $headers = @{ Authorization = "token $apitoken" }
PS /Users/greg> $resp = Invoke-RestMethod -Uri https://api.github.com/notifications -Headers $headers
PS /Users/greg> $resp -eq $null                                                                                                     
PS /Users/greg>

What is returned is an Object.

PS /Users/greg> $resp -is [System.Object]                                                                                           
True
PS /Users/greg> 

Should be no different than this.

PS /Users/greg> $obj = New-Object System.Object                                                                                     
PS /Users/greg> $obj -eq $null                                                                                                      
False
PS /Users/greg> 

Expected behavior

PS /Users/greg> $resp -eq $null
True
PS /Users/greg>

Actual behavior

PS /Users/greg> $resp -eq $null
PS /Users/greg>

Environment data

Name                           Value                                                                                               
----                           -----                                                                                               
PSVersion                      6.0.0-beta.9                                                                                        
PSEdition                      Core                                                                                                
GitCommitId                    v6.0.0-beta.9                                                                                       
OS                             Darwin 17.2.0 Darwin Kernel Version 17.2.0: Fri Sep 29 18:27:05 PDT 2017; root:xnu-4570.20.62~3/R...
Platform                       Unix                                                                                                
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                             
PSRemotingProtocolVersion      2.3                                                                                                 
SerializationVersion           1.1.0.1                                                                                             
WSManStackVersion              3.0

This occurs for Windows PowerShell versions too.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking-Changebreaking change that may affect usersbreaking change that may affect usersCommittee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIssue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.