rest - 无法查询 JavaScript REST API
问题描述
我正在编写 PowerShell 脚本来列出页面https://testpage.com/api/usergroups中的所有信息。
怎样才能得到输出?
为此,我使用了下一个代码
function Get-Data([string]$username, [string]$password, [string]$url) {
# Step 1. Create a username:password pair
$credPair = "$($username):$($password)"
# Step 2. Encode the pair to Base64 string
$encodedCredentials =[System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($credPair))
# Step 3. Form the header and add the Authorization attribute to it
$headers = @{ Authorization = "Basic $encodedCredentials" }
# Step 4. Make the GET request
$responseData = Invoke-WebRequest -Uri $url -Method Get -Headers $headers -UseBasicParsing
return $responseData
}
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Get-Data -username user -password pass -url https://testpage.com/api/usergroups
结果我得到了下一个错误
<noscript>
<p>
<strong>Note:</strong> Since your browser does not support JavaScript,
you must press the Continue button once to proceed.
</p>
</noscript>
解决方案
推荐阅读
- c - 这个输入有什么问题?我在这个程序中遇到分段错误(核心转储)
- javascript - makeStyles 的 Material-UI 问题
- amazon-web-services - 如何使用 AWS CLI 从 EBS 快照创建 AMI
- python - 当我对它进行 dckerize 时,Python3 os.popen 不能与 Nmap 一起使用
- html - 重置给定元素的样式,但保留 HTML 属性样式
- odata - Odata v4 - hasPendingChanges
- linux - 根据图像大小将画布添加到高度或宽度
- python - 使用正则表达式删除文件中的第 N 次出现
- c++ - C++ 装饰器:从外部访问基类的公共函数
- kubernetes - 为什么 treafik https 配置在 kubernetes 集群中不起作用