Skip to content
DataMiner DoJo

More results...

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Search in posts
Search in pages
Search in posts
Search in pages
Log in
Menu
  • Updates & Insights
  • Questions
  • Learning
    • E-learning Courses
    • Empower Replay: Limited Edition
    • Tutorials
    • Open Classroom Training
    • Certification
      • DataMiner Fundamentals
      • DataMiner Configurator
      • DataMiner Automation
      • Scripts & Connectors Developer: HTTP Basics
      • Scripts & Connectors Developer: SNMP Basics
      • Visual Overview – Level 1
      • Verify a certificate
    • Video Library
    • Books We Like
    • >> Go to DataMiner Docs
  • Expert Center
    • Solutions & Use Cases
      • Solutions
      • Use Case Library
    • Markets & Industries
      • Media production
      • Government & defense
      • Content distribution
      • Service providers
      • Partners
      • OSS/BSS
    • Agile
      • Agile Webspace
      • Everything Agile
        • The Agile Manifesto
        • Best Practices
        • Retro Recipes
      • Methodologies
        • The Scrum Framework
        • Kanban
        • Extreme Programming
      • Roles
        • The Product Owner
        • The Agile Coach
        • The Quality & UX Coach (QX)
    • DataMiner DevOps Professional Program
      • About the DevOps Program
      • DataMiner DevOps Support
  • Downloads
  • More
    • DataMiner Releases & Updates
    • Feature Suggestions
    • Climb the leaderboard!
    • Swag Shop
    • Contact
    • Global Feedback Survey
  • PARTNERS
    • All Partners
    • Technology Partners
    • Strategic Partner Program
    • Deal Registration
  • >> Go to dataminer.services

Can we call another automation script from API automation script?

Solved355 views2nd August 2024#automationscript
0
Apurva Tandon [DevOps Advocate]1.61K 1st August 2024 0 Comments

How can we call an automation script which is normal, from this type of script
[AutomationEntryPoint(AutomationEntryPointType.Types.OnApiTrigger)]

For eg.

/// <param name=”requestData”></param>
[AutomationEntryPoint(AutomationEntryPointType.Types.OnApiTrigger)]
public ApiTriggerOutput CreateEventMonitoringService(IEngine engine, ApiTriggerInput requestData)
{
InitializeEngine(engine);
var subScript = _engine.PrepareSubScript(“Sky_Refresh_Service_Background_1”);
subScript.SelectScriptParam(“jsonData”, JsonConvert.SerializeObject(requestData));
subScript.Synchronous = false;
subScript.StartScript();
var jsonData = DeserializeRequestData(requestData.RawBody);
var serviceParams = new List<ServiceInfoParams>();

will this code work, like it will send the info to other service

and also, in the script which I am calling , I am adding it in scheduler to call after every one minute wherein I am using this variable
private static Dictionary<string, RequestBody> servicesInfo = new Dictionary<string, RequestBody>();

So, want to know when from scheduler this script will start will it reinitalize this dictionary to 0?
As from API script I am sending the data to this another script which will be called on scheduler after every 1 min

Apurva Tandon [DevOps Advocate] Selected answer as best 2nd August 2024

1 Answer

  • Active
  • Voted
  • Newest
  • Oldest
1
Thomas Ghysbrecht [SLC] [DevOps Enabler]4.84K Posted 2nd August 2024 0 Comments

Hi Apurva,

From what I can tell, the code you shared should work in general. I do want to share some tips however:

  • I see that the ‘ApiTriggerInput’ request data is being serialized to JSON so it can be passed to the subscript. I would advice against serializing types that are not under your control. It is safer to first map the data in the input object to an object based on a class that you created. That way, you have full control on the data that is being sent to the subscript and can guarantee that it is actually serializable and will remain so after updates.
  • If this API script doesn’t need to do anything else than triggering the ‘Sky_Refresh_Service_Background_1’ script, you could look into adding this ‘CreateEventMonitoringService’ entrypoint method to that script instead. This way, you don’t need to start other scripts and you have access to the code inside that refresh script. It is possible to have a script with multiple entrypoints, one being the normal ‘Run’ method and one being the ‘OnApiTrigger’ entrypoint.

On the question with the static field. I believe that the static dictionary will remain initialized and maintain the same data throughout script executions. Do however note that this could lead to memory leaks if the items in the dictionary never get removed. (Either because there is no remove logic, or the flow that should remove an item was interrupted now and then, resulting in the items being stuck forever.)

Apurva Tandon [DevOps Advocate] Selected answer as best 2nd August 2024
Please login to be able to comment or post an answer.

My DevOps rank

DevOps Members get more insights on their profile page.

My user earnings

0 Dojo credits

Spend your credits in our swag shop.

0 Reputation points

Boost your reputation, climb the leaderboard.

Promo banner DataMiner DevOps Professiona Program
DataMiner Integration Studio (DIS)
Empower Katas
Privacy Policy • Terms & Conditions • Contact

© 2025 Skyline Communications. All rights reserved.

DOJO Q&A widget

Can't find what you need?

? Explore the Q&A DataMiner Docs