【发布时间】:2021-06-13 01:19:40
【问题描述】:
我在 powershell 中做一个 Get-Weather 项目,我从 weatherapi.com 中提取数据。我能够使用 API 密钥成功连接到网站,但是当我尝试从脚本中的 json 转换它时,它不起作用。我得到的错误是:
“无法绑定参数'Uri'。无法转换...” 我尝试了很多不同的方法来写这个:
$response = Invoke-RestMethod -uri $url -Method Get -ResponseHeadersVariable r -StatusCodeVariable s
$weatherobject = ConvertFrom-Json $url
对网站的请求是:
$url = Invoke-WebRequest "http://api.weatherapi.com/v1/forecast.json?key=$key&q=$location&days=$Days"
非常感谢您的帮助,谢谢!
【问题讨论】:
标签: json powershell api weather-api