1
如果對象創建代碼是單行的,我能夠傳遞動態json對象。動態Json變量來調用Invoke-Restmethod
Invoke-RestMethod -ContentType "application/json" -Method Post -Body '{ "name" : "azurefunctionapp2email", "appname": "Applicationnamehere", "requestedBy" : "requestedby", "reqdate" : "requestdate", "status" : "Successfully Deployed", "AppsCount" : "2" }' `
-Uri 「https://implementurihere"
由於在現實世界中的動態JSON對象需要更長,我分隔新線and referenced in the above as below. But new line shift
使JSON打破創建。我試圖管ConvertTo-Json
函數,然後發現輸出持有「`\ r \ n」越來越介紹:
$body = '{ "name" : "azurefunctionapp2email", `
"appname": "Applicationnamehere", `
"requestedBy" : "requestedby", `
"reqdate" : "requestdate",
"status" : "Successfully Deployed",
"AppsCount" : "2" }' `
Invoke-RestMethod -ContentType "application/json" -Method Post -Body $body `
-Uri 「https://implementurihere"
注:以上的作品,如果$body
是單行。
如何在這樣的場景中創建動態json,長文件和提要?
是的,非常感謝。 –