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,
We can see in the response that you get errorCode:12. This indicates the following:
AutomationActionError: An error occurred while trying to execute an Automation script action.
The full list of error codes can be found here: https://docs.dataminer.services/user-guide/Advanced_Modules/User%20Defined%20APIs/UD_APIs_Triggering_an_API.html
So it looks like your automation script has an error. My suggestion would be to look inside the C# Code of your automation script, and validate the code.
If you would like to have more information on the User-Defined API, this 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
On the above link you'll find an example of a script that you can copy into your code.
Hope this helps you with debugging your issue.
Kind regards,
Thanks for the reply.
I read what was presented.
I understood that this is not a simple call to Automation, but an API that calls the C# code described in Automation.
Unfortunately, I no longer have use to this functionality as I am not in an environment where I can develop.
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!
Additionally, I believe the root cause of the problem here is that your automation script was not built using a c# code block.
This Automation script needs the OnApiTrigger entry point method defined in a c# code block to function.