如果我在Invoke-Webrequest中编写PowerShell代码来最小化响应,如何转换"prefer=minimal“请求头?
$Data = Invoke-WebRequest -Headers $authHeader -Uri $Url -Body $body -Method POST -UseBasicParsing -ContentType "application/json; charset=utf-8" -prefer "return=minimal"
这段代码不能从我这一端运行。
发布于 2019-06-09 23:36:05
Invoke-WebRequest
不支持Prefer
参数,需要通过Headers
参数指定,例如:
$Url = "https://graph.microsoft.com/v1.0/users/delta?`$select=displayName,jobTitle,mobilePhone"
$headers = @{
Authorization="Bearer $token"
Prefer="return=minimal"
}
$Data = Invoke-WebRequest -Headers $headers -Uri $Url -Method GET -ContentType "application/json"
https://stackoverflow.com/questions/56486890
复制相似问题