I have a problem using the "Call REST API" function
1- I add a field of type "text area" inside a rule (see image 1a.png and 1b.png)
2- Within the workflow I call a function called "Call REST API" and in the pre-script I refer to the field "description" created in point 1. (see image 2.png)
3- Then the verifiable "Description1" should be entered as part of the "inputs.rest_body" (see image 3.png)
4- Finally I will perform a test of the action "Abrir Peticion" that calls the workflow of point 3. Request that you complete the fields of point 1. As an example, enter text multi line (see image 4a.pgn and 4b.png )
As a result I get an error because I can not interpret the json (see image log.png)
The response of the rest:
2019-02-05 22:59:00,882 DEBUG [actions_component] Result: {'cookies': {}, 'links': {}, 'text': u'{\n "Messages": ["JSONException: Unterminated string at character 304"],\n "ReturnCode": "-5"\n}', 'elapsed': 61, 'apparent_encoding': 'ascii', 'reason': 'Bad Request', 'ok': False, 'url': u'http://10.4.0.14:25001/SM/9/rest/ResilientQ/', 'headers': {'Content-Length': '95', 'X-Content-Type-Options': 'nosniff', 'Keep-Alive': 'timeout=1200000, max=1000', 'Server': 'Apache-Coyote/1.1', 'Connection': 'Keep-Alive, close', 'Date': 'Wed, 06 Feb 2019 02:14:06 GMT', 'Content-Type': 'application/json;charset=utf-8'}, 'json': {u'ReturnCode': u'-5', u'Messages': [u'JSONException: Unterminated string at character 304']}, 'status_code': 400}
If the json be formed as follows this would work:
2019-02-05 22:59:00,307 INFO [utilities_call_rest_api] rest_body:
{
"ResilientQ": {
"Categoria": "Seguridad",
"Subcategoria": "Seguridad -- Antivirus -- Consulta",
"GrupoAsignado": "SEGURIDAD-ANTIVIRUS",
"SolicitadoPara": "falcon",
"FechaRequerida": "2019-02-28T03:00:00",
"SolicitadoPor": "falcon",
"Descripcion": ["Test of a text line 1\nTest of a text line 2\nTest of a text line 3\nTest of a text line 4"],
"Titulo": "Prueba",
"GrupoRegistradoPor": "SEGURIDAD-ANTIVIRUS",
"Fase": "Registro"
}
}
Another error occurs if the text has special characters such as \ or / or "
for example (see image 5.png), in the app.log:
2019-02-05 23:08:24,764 INFO [utilities_call_rest_api] rest_body:
{
"ResilientQ": {
"Categoria": "Seguridad",
"Subcategoria": "Seguridad -- Antivirus -- Consulta",
"GrupoAsignado": "SEGURIDAD-ANTIVIRUS",
"SolicitadoPara": "falcon",
"FechaRequerida": "2019-02-28T03:00:00",
"SolicitadoPor": "falcon",
"Descripcion": ["Test of a text "line" 1
Test of a text line 2
Test of a text \line\ 3
Test of a text /line"/ 4"],
"Titulo": "Prueba",
"GrupoRegistradoPor": "SEGURIDAD-ANTIVIRUS",
"Fase": "Registro"
}
}
2019-02-05 23:08:25,165 DEBUG [actions_component] Result: {'cookies': {}, 'links': {}, 'text': u'{\n "Messages": ["JSONException: Expected a \',\' or \']\' at character 299"],\n "ReturnCode": "-5"\n}', 'elapsed': 6, 'apparent_encoding': 'ascii', 'reason': 'Bad Request', 'ok': False, 'url': u'http://10.4.0.14:25001/SM/9/rest/ResilientQ/', 'headers': {'Content-Length': '97', 'X-Content-Type-Options': 'nosniff', 'Keep-Alive': 'timeout=1200000, max=1000', 'Server': 'Apache-Coyote/1.1', 'Connection': 'Keep-Alive, close', 'Date': 'Wed, 06 Feb 2019 02:23:34 GMT', 'Content-Type': 'application/json;charset=utf-8'}, 'json': {u'ReturnCode': u'-5', u'Messages': [u"JSONException: Expected a ',' or ']' at character 299"]}, 'status_code': 400}
Can you help me solve this problem? Maybe with some regular expression or replace we can do something.
Thank you!
------------------------------
Juan Cruz Del Col
------------------------------