eNMS-automation / eNMS

An enterprise-grade vendor-agnostic network automation platform.

Home Page:https://www.enms.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rest_call_service is not working as expected

sproot1979 opened this issue · comments

Hello,

I created a service with type rest_call_service with parameters:
Call Type = POST
Rest Url = http://192.168.147.141:5000/api/init
Run Method = Run the service once
Devices = device1 and device2

How can i send json to have these devices(device1 and device2) in it? What should be in Payload?
I've tried many different ways, including using the "target_devices" variable, but nothing seems to work.
I need to call the POST method once in which to somehow specify a list of devices.

Second question: can rest_call_service send a request with "Content-Type: application / x-www-form-urlencoded"?

through tcpdump I saw this dir() return:
... [{"data":. "['
__builtins__ ',.'
device ',.' device
s ',.' dict_to_str
ing ',.' encrypt ',
.'fetch ',.' fetch
_all ',.' get_resu
lt ',.' get_var ',.
'log',. 'parent_d
evice ',.' payload
',.' placeholder '
,. 'run',. 'self',
.'send_email ',.'
set_var ',.' setti
ngs',. 'workflow'
] "}

the devices list contains what I need. As a result, Payload turned out like this: {"data":"{{devices}}"}
The data is as follows:
....{"data":."[s
1-r2.ams4.(BR-VD
X6740T),.s1-r1.a
ms4.(BR-VDX6740T
)]"}
Device type is this a required field?

Hello,
Payload = {"data": "{{devices}}"} works, but how to get the correct json? I would like to do this: Payload = {"data": {{devices}}}, but an error pops up in the UI: Wrong input for "payload": Invalid json syntax. This is most likely due to the "sub" method in the "Run" class.

{"data": devices}, {{}} is for string substitution

{"data": devices}, {{}} is for string substitution

Does not work. Error: Wrong input for "payload": Invalid json syntax. I checked this right away.
ENMS v4.0.0

Please reopen a ticket, I do not see how this can be done

@sproot1979 Were you ever able to figure this out? I'm trying to substitute devices at runtime as well, but keep running into a wall.