4 Replies Latest reply on Aug 25, 2015 7:33 AM by Derrick Swinarsky

    How to invoke NSHScript Job with Input Parameters using SOAP API

      I have been trying to execute a nshscriptjob with the hostname as an input parameter, and so far, I haven't been succesfull. But, I was able to call a NSCHScriptJob with out any parameters succesfully. Here are the basic steps I have been following..

       

      First Get a session Id and AssumeRole, then use that loginsessionId, I have made the following type of request to get the job dbkey =

       

      **This is a java script SOAP request built, nothing fancy..

       

      var operation = host.getOperation("executeCommandByParamList");

      var request = operation.createSOAPRequest();

      request.setInHeader("sessionId",sessionId);

      request.setInParameter("nameSpace","NSHScriptJob");

      request.setInParameter("commandName", "getDBKeyByGroupAndName");

      request.setInParameter("commandArguments[0]",groupName);

      request.setInParameter("commandArguments[1]",jobName);

      var response = operation.invoke(request);

       

      This works with out any issues and I use this inturn to call the next action "executeJobAndWait" using the dbkey and it works like a charm.

       

      var request = operation.createSOAPRequest();

      request.setInHeader("sessionId",loginSessionId);

      request.setInParameter("nameSpace","NSHScriptJob");

      request.setInParameter("commandName","executeJobAndWait");

      request.setInParameter("commandArguments[0]", NSHJobDBKey);

      var response = operation.invoke(request);


      Now, my question is - how do I provide a input argument to this nshscript if its expecting one, in my case, I would like to provide a hostname. I tried by adding that at "getDBKeyByGroupAndName" as follows =


      request.setInParameter("commandArguments[2]","test_host_name");


      And subsequently with "executeJobAndWait" with proper indexing, and it returned the same error as below:


      Found command 'NSHScriptJob.executeJobAndWait' but with mismatching arguments. 


      Any help in this regarding would be really appreciated.