gpt4 book ai didi

Powershell Invoke-RestMethod 不正确的字符

转载 作者:行者123 更新时间:2023-12-04 13:22:27 25 4
gpt4 key购买 nike

我正在使用 Invoke-RestMethod 从我正在使用的应用程序中获取页面名称。我注意到当我在页面上执行 GET 时,它会像这样返回页面名称

This page â is working



但是实际的页面名称是

This page – is working



这是我的请求的样子
 Invoke-WebRequest -Uri ("https://example.com/rest/api/content/123789") -Method Get -Headers $Credentials -ContentType "application/json; charset=utf-8"

问题出在破折号上,有谁知道我该如何解决这个问题?

最佳答案

如果 Invoke-WebRequest 没有检测到响应编码权限,可以使用 RawContentStream 并将其转换为所需的编码:
$resp = Invoke-WebRequest -Uri ...
$html=[system.Text.Encoding]::UTF8.GetString($resp.RawContentStream.ToArray());

关于Powershell Invoke-RestMethod 不正确的字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35858490/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com