我有一些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
我在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"
}
}
'@