Hi Skyline Team
The API in DataMiner Automation added in 10.3.6.0 is interesting to me.
I tested it immediately.
I created a simple script to Pause and Start an element as Automation.
Created an endpoint in User-defined API
Of course, the token is created.
When I posted with Postman, it returned a 500 error.
I think this is a simple API that does not require an output, am I doing something wrong?
Hi Yuki,
As Ive mentioned, the issue you have is indeed that only automation scripts with a single C#code block as action are supported. On top of that, the C# code block needs the OnApiTrigger entry point method. More info can be found here: https://docs.dataminer.services/user-guide/Advanced_Modules/User%20Defined%20APIs/Defining_an_API/UD_APIs_Defining_a_new_API.html
We actually have an example in our documentation that is somewhat similar to what you are trying to test, that you can use as a reference for creating your scripts to start and pause your element: https://docs.dataminer.services/user-guide/Advanced_Modules/User%20Defined%20APIs/Defining_an_API/UD_APIs_Examples.html#onapitrigger-method-with-dictionary-parsing-from-json
In the example above, we create an APÏ that changes a parameter value of an element. You could change this script to have the DataMiner ID and Element ID as parameters, and you could change the lines of code that change the parameter value to the following for stopping an element. Starting an element would be the same, only replace the Stop() method with the Start() method:
var element = engine.FindElement(dmaId, elementId);
element.Stop();
If for your use-case there is no need to send a response back to the user, you could just return a 204 (No Content) response code, with an empty response message:
return new ApiTriggerOutput()
{
ResponseBody = "",
ResponseCode = (int) StatusCode.NoContent
};
For your use-case, I would create only 1 automation script for the two APIs. You can create a condition in your script that checks the URL route it was triggered on, based on that info, you can either pause or start your element in the same automation script.
I hope this helps you further in exploring the user-defined APIs feature!