5 Replies Latest reply on Aug 29, 2013 5:09 PM by Ryan Koziel

    export NSH job results via Web Services



      I'm trying to export nsh job results via Web Services and receive following error:


      Wrong Service Call. Please use the attachment service api, for cli commands involving attachments.


      Any ideas how to solve it?



      Thanks in advance.

        • 2. Re: export NSH job results via Web Services
          Ryan Koziel

          Crazy, I just hit this same error today under SOAP and CLITunnelService from .NET/C#. I was attempting to run 'Virtualization createVirtualGuest' using CLI.executeCommandByParamList, which threw the same error.


          I see this available under the CLI though (haven't tried it just yet as I just found this "web method"):




          Please let me know if that helps you out, I'll reply back once I'm able to confirm it.


          UPDATE: There is also this:



          • 3. Re: export NSH job results via Web Services
            Bill Robinson

            did you get the 'executeCommandUsingAttachments' working to get the exported job run log ?

            • 4. Re: export NSH job results via Web Services
              Ryan Koziel

              I did not get 'executeCommandUsingAttachments' to work with the methods I am calling (Virtualization: createVirtualGuestPackage & createVirtualGuest). I had to use 'executeCommandByParamListAndAttachment'. I believe it has something to do with the direction of the attachment; I am sending a VGJ.xml or VGP.xml to the application server as an array of bytes in the call whereas it looks like whatever class & command Darius is using will be sending an attachment back to the client.


              I am not sure which class & method Darius was attempting to call that would send back an attachment containing the job results of a NSH script job...I didn't see any methods under the NSHScriptJob class, there might be a few under JobRun that would do it. If someone can elaborate on what class & method are being called I can give it a shot using 'executeCommandUsingAttachments' if I can figure out the ClientPayLoad object.

              • 5. Re: export NSH job results via Web Services
                Ryan Koziel

                Darius/Bill - I was able to get 'executeCommandByParamListAndAttachment' to work using the methods 'exportsBatchRun', 'exportDeployRun' and 'exportNSHScriptRun' in the 'Utility' namespace.


                Here's a snippet of what I did (C#). The result is that the file is written to outputFilePath locally where the this call is made.


                // arguments to the method

                string[] cmdArgs = new string[2];

                cmdArgs[0] = jobRunId;

                cmdArgs[1] = outputFilePath;


                // setup file to house the results and use for byte array

                FileStream fs = File.Create(outputFilePath);



                byte[] byteArray = File.ReadAllBytes(outputFilePath);

                Result res = CLI.executeCommandByParamListAndAttachment("Utility", "exportNSHScriptRun", cmdArgs, byteArray);

                if (res.success)

                     File.WriteAllBytes(outputFilePath, res.attachment[0]);