3 Replies Latest reply on Nov 10, 2011 4:57 PM by jking

    uploadFile parameter in Linux CLI


      I apologize if this seems like a reposting from a similar issue discussed a few weeks back by jbrooks over at Re: policy.importPolicy issue           , but his pertained to Python's interpretter of the file:/// input.  I am trying to perform an ImportTag query to upload a tag.xml file from my Linux box via CLI. 

      The file is located at: /home/parker/projects/project1/project1_tag.xml

      so I have tried try:

      query: /remote/system.importTag(uploadFile='file:///home/parker/projects/project1/proj ect1_tag.xml')

      query: /remote/system.importTag(uploadFile='file:////home/parker/projects/project1/pro ject1_tag.xml')

      query: /remote/system.importTag(uploadFile='/home/parker/projects/project1/project1_ta g.xml')


      and none of them work.  Has anyone tried doing this from bash and are you having any success?  If so what is the path you are passing the uploadFile argument?




        • 1. Re: uploadFile parameter in Linux CLI

          For commands that accept a file, it need to be in a posted form value, not a parameter.  The parameter name should be the form-field.  So if you're using curl, you can use something like:


          curl -k -u <user>:<pass> https://localhost:8443/remote/core.importPermissionSets.do -F file=@ps.xml


          The @filename is the magic sauce for curl to read the contents of the file into the form-field value. 



          • 2. Re: uploadFile parameter in Linux CLI

            Jon,  I try this with the importTag operator, and I get the following:


            curl -k -u <user>:<password> https://<server>:8443/remote/system.importTag -F file=@file.xml

            Error 0 :

            Error setting parameters for command: system.importTag


            I've also tried:

            curl -k -u <user>:<password> https://<server>:8443/remote/system.importTag.do -F file=@file.xml


            and I get the same error message.




            • 3. Re: uploadFile parameter in Linux CLI

              jking@ src $ curl --silent -qk -u <user>:<pass> 'https://<hostname>:8443/remote/core.help?command=system.importTag'


              system.importTag uploadFile [force]

              Imports Tags from the xml file

              Requires tag create permission


              [uploadFile (param 1) | filePath] - Path to a local XML file

              force (param 2) - If true, overwrites the existing tags. Defaults to false.


              In the curl command line, the -F tells curl to do a post, but in XXX=@yyy, the XXX is the field name -- for system.importTag that should use the parameter "uploadFile".  So -F uploadFile=@file.xml should be the trick.