JIRA HTTP调用中的换行符

时间:2018-07-12 07:03:02

标签: api jira

我的自动化设置对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 value\n at [Source: org.apache.catalina.connector.CoyoteInputStream@39cf8e10; line: 14, column: 62]"]}

如何实现变量以使格式不中断?

1 个答案:

答案 0 :(得分:1)

This post建议您将换行符替换为转义的换行符(即,在发送变量之前,对其进行迭代,然后将所有\n替换为\\n