Skip to content

Commit

Permalink
API fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusStorhaug committed Dec 9, 2024
1 parent 3bf7e10 commit 736ed99
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/CallingAPIs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ Invoke-GitHubAPI -ApiEndpoint /zen
# Most complex example - output is the entire web response
$context = Get-GitHubContext
Invoke-WebRequest -Uri "https://api.$($context.HostName)/zen" -Token ($context.Token) -Authentication Bearer
Invoke-RestMethod -Uri "https://api.$($context.HostName)/octocat" -Token ($context.Token) -Authentication Bearer
#endregion
7 changes: 6 additions & 1 deletion src/functions/public/API/Invoke-GitHubAPI.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,15 @@
'text/plain' {
$results = $response.Content
}
'application/octocat-stream' {
[byte[]]$byteArray = $response.Content
$results = [System.Text.Encoding]::UTF8.GetString($byteArray)
}
default {
Write-Warning "Unknown content type: $($headers.'Content-Type')"
Write-Warning 'Please report this issue!'
$results = $response.Content
[byte[]]$byteArray = $response.Content
$results = [System.Text.Encoding]::UTF8.GetString($byteArray)
}
}
[pscustomobject]@{
Expand Down

0 comments on commit 736ed99

Please sign in to comment.