eNMS-automation / eNMS

An enterprise-grade vendor-agnostic network automation platform.
https://www.enms.io/
GNU General Public License v3.0
812 stars 162 forks source link

rest_call_service is not working as expected #365

Closed sproot1979 closed 3 years ago

sproot1979 commented 3 years ago

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"?

sproot1979 commented 3 years ago

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?

sproot1979 commented 3 years ago

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.

afourmy commented 3 years ago

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

sproot1979 commented 3 years ago

{"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

adparis99 commented 2 years ago

@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.