powershell中的cURL不起作用

问题描述 投票:0回答:1

我有一些JSON,我正在尝试使用curl。

$json = [char]93 + "{"fields":{"project":{"key":"TEST"},"summary":"Test of the REST","description":"Issue created using the REST API","issuetype":{"name":"Bug"}}}` + [char]93

我使用过[char]39因为我不能在变量中使用'字符。

我正在尝试使用JIRA Rest API和PowerShell发布此JSON。我已经检查了JSON的格式和cURL是否正常(在Linux主机上测试过)。不幸的是,以下命令对我不起作用。

curl https://jira.internal/rest/api/2/issue/ -f -u user:p@ssw0rd! -H "Content-type:application/json" -X POST -d $json
powershell curl command-line
1个回答
0
投票

我在Windows中的PowerShell 4.0中遇到了同样的问题,并通过linebrackets和“@”符号解决了它。试试以下:

$json= @'
{
   "fields":{
       "project":{"key":"TEST"}
   },
   "summary":"Test of the REST",
   "description":"Issue created using the REST API",
   "issuetype":{
        "name":"Bug"
   }  
}
'@
© www.soinside.com 2019 - 2024. All rights reserved.