Can I call (run) a global function, already set in the router, via API?
I have set a global function (AddWallgardenDeletionScheduler) that takes 2 parameters but when I try to call it from API doesn’t seem to find it. (Doesn’t give an error - it’s as if it was never been set)
Unfortunately any script that you run via the API, cannot use (find) any global variables which is very peculiar. If you run the same script from a terminal it can use the global variable just fine but if you run it via the API it doesn’t.
The official response from Mikrotik support to this was:
Hello,
Unfortunately it is not possible. API is for configuration management and monitoring not running and writing scripts.
To be able to access variables (in general), the user you access the router with needs to have both read and write policies… and I think the “policy” policy as well. Anything less will not be able to access variables in any fashion.
If you’re not willing to give up this security, I’d suggest you translate your script into API calls or at least boil it down to a single “execute” call where the source contains the actual values (that you’ll replace before making the call).