Hi,
What’s the procedure to trigger an easymorph server task via API calls?
Thanks
Nikolaas
Hi,
What’s the procedure to trigger an easymorph server task via API calls?
Thanks
Nikolaas
The simplest way is to use the ems-cmd
utility that comes with an EasyMorph Server installation, or can be installed independently.
The utility and documentation on it can be found here: https://github.com/easymorph/server-cmd
Hello,
I’m also interested in triggering EasyMorph Server tasks via API Calls. I have a basic question (just starting with this ):
How does an external API call ems-cmd in a certain computer? For now I’ve been calling Web APIs from EasyMorph, being the endpoint a Web URL. However, in this case, how can an external API call EasyMorph through the command line? What would the equivalent “Base URL” be in this case?
Can you provide me an example of how this process would work? I’m really interested in understanding the flow of events and where the calls have to be directed.
Thanks very much,
Roberto
Hi Roberto,
the ems-cmd
utility is a command-line client for the EasyMorph Server API. It must be run as a program by the external application.
In other words, ems-cmd
is a utility that converts command-line arguments into API calls to EasyMorph Server so that external applications don’t have to construct the API interaction logic themselves.
Another way to trigger a Server task is to use a light webhook. Tick the “Enable Get” checkbox and the webhook URL will be generated an enabled. When you open the URL from a browser, or send a GET request to the URL from another application, the task will be triggered automatically.
The screenshot above is made on a local Server installation, hence localhost
in the URL. In real life, there should be a real host name.
Note that you can also specify task parameters as URL parameters in the webhook URL.
Hello Dmitry,
Thanks for your reply. Ok, so regarding ems-cmd, it’s not installed in the computer where EasyMorph server is installed, but in the computer where EasyMorph Server should be invoked from. So a command-line argument is inserted into ems-cmd in one computer, which sends it to the computer where EasyMorph Server is installed, and converts this command-line argument into an API call, so that EasyMorph server can interpret it and execute the action (like run a task, for example), correct?
Regarding the webhook, I think this is what I’m looking for. Regarding this GET request, what is the “base URL” and the “Path”, in this case? Is there a possibility that some identification has to be added as a header in the GET request or such so that only people with a certain password can actually execute the task, or anyone with the link can execute the task?
Finally, in the URL in your screenshot, I see that it starts with "space/default/tasks/start. Are there other options apart from starting a task? Like for example listing the existing tasks in that space, listing possible parameters, etc.
I’ve been looking in the EasyMorph Server Admin Guide and there’s no info about the webhooks, is this something new?
Thanks a lot!
Roberto
Yes, that’s correct.
There is no strict definition of a base URL - it’s what you make it. Why do you need the base URL? Typically you will be the whole URL to be invoked, not just a part of it.
You can add a task parameter named, for instance, key
. Then append ?key=12345
to the webhook URL to assign the key value. In the project, check that the key is valid.
This can be done with the ems-cmd utility. See the ems-cmd documentation for all possible commands.
Ok, thanks for the clarifications. Regarding adding parameters to the URL, should they be separated with “&” in the URL? Can you provide a sample URL with some paramaters?
Thanks!
Roberto
There are many resources on the internet regarding URL parameters. For instance, see here: https://en.wikipedia.org/wiki/Query_string