我的自动化设置对JIRA进行HTTP调用,其中包括从之前的测试结果中提取的变量。变量有时会有换行符,因为语法问题导致HTTP调用出错。
{
"fields": {
"project":
{
"key": "Blah"
},
"assignee": {
"name": "Joe"
},
"summary": "Summary",
"description": "${variable}",
"issuetype": {
"name": "Defect"
}
}
在HTTP调用中,${variable}被替换为:
{
"fields": {
"project":
{
"key": "Blah"
},
"assignee": {
"name": "Joe"
},
"summary": "Summary",
"description": "Test failed: text expected to equal /
****** received :
[[[{"id":700,"status":"FAIL","color":"#D45D52","testKey":"TEST-329","testExecKey":"TEST-355","assig...]]]
****** comparison: [[[asdasdasdasd
]]]
/",
"issuetype": {
"name": "Defect"
}
}
作为回应,我得到的是:
{"errorMessages":["Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string valuen at [Source: org.apache.catalina.connector.CoyoteInputStream@39cf8e10; line: 14, column: 62]"]}
如何实现变量,使格式不中断?
这篇文章建议您应该用转义的换行符替换换行符(即,在发送变量之前,遍历变量并用\n
替换所有n
(