且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法使用PowerShell张贴Cosmos DB存储过程

更新时间:2023-02-14 12:33:35

所以事实证明请求主体是错误的.应该是这样的:

So turns out the request body was wrong. It should be like this:

{
    "body":"function HelloWorld() {\r\n    var context = getContext();\r\n    var response = context.getResponse();\r\nresponse.setBody(\"Hello, World\");\r\n}",
    "id": "HelloWorld"
}

这是存储过程可接受的请求正文.因此,我应该将$ HelloWorld变量设置为:

That's the acceptable request body for Stored Procedures. So what I should have done is set my $HelloWorld variable to:

$HelloWorld = Get-Content -Path '.\Databases\MyCosmosDB\MyCosmosCollection\Stored Procedures\HelloWorld.json' | Out-String

希望我的愚蠢有一天能帮助某人:/

Hope my stupidity helps someone someday :/