我需要使用Powershell向Web api发送一个简单的字符串,并且我必须确保HTML正文中的值周围带有“Quotes”,因为内容类型必须为application/json。
例如:
$specialKey = "101010"
Invoke-RestMethod -Method Put `
-Uri $keyAssignmentUri `
-Header @{"content-type"="application/json"} `
-Body "$specialKey"
当我在Fiddler中检查此调用时,我看到主体是101010,而不是“101010”。如何发送带有引号的正文值?
最佳答案
用单引号将其括起来,使其成为文字字符串:
$specialKey = '"101010"'
关于rest - 如何在Powershell字符串中转义 "Quotes"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44840644/