VMware Cloud Community
ericr999
Enthusiast
Enthusiast
Jump to solution

HTTP-REST download zip file

Hello,

Trying to automate Nessus with VRO so that when we build machines once everything is done, we can run a first scan and retrieve the report. Nessus seems to be able to generate a .csv that is stored in a zip file. I'm trying to download that ZIP file into a Ressource Element. But from what I see, the RESTOperation object seems to store the reply in a string in the variable response.contentAsString.

I've used the Generate workflow for the REST Operation, and added a few lines if I remember.

It looks like this:

//prepare request

//Do not edit

System.log("==== Execution du WF POST ======");

restOperation.urlTemplate = restOperation.urlTemplate + uri;

var inParamtersValues = [];

var request = restOperation.createRequest(inParamtersValues, content);

var noToken = new Number(token);

//set the request content type

request.contentType = "application/zip";

request.setHeader("X-SecurityCenter", noToken);

System.log("Request: " + request);

System.error("Request URL: " + request.fullUrl);

//Customize the request here

//request.setHeader("headerName", "headerValue");

//execute request

//Do not edit

var response = request.execute();

System.log("request:"+request.contentType);

System.log("response:"+response.contentType);

//prepare output parameters

System.log("Response: " + response);

statusCode = response.statusCode;

statusCodeAttribute = statusCode;

System.log("Status code: " + statusCode);

contentLength = response.contentLength;

headers = response.getAllHeaders();

contentAsString = response.contentAsString;

System.log("Content a

s string: " + contentAsString);

But I don't want to retrieve the content as a String, is there another way to receive a binary file via VRO. ? My next step would be to run this on another machine with curl maybe.

Thanks,

Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

One option is to try Joerg Lew's download plugin (check the following threads for details -  http://https://communities.vmware.com/thread/545356 and https://communities.vmware.com/thread/538137 )

curl would also do; the first link above shows a sample showing how to invoke it using vRO command class.

View solution in original post

Reply
0 Kudos
5 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

One option is to try Joerg Lew's download plugin (check the following threads for details -  http://https://communities.vmware.com/thread/545356 and https://communities.vmware.com/thread/538137 )

curl would also do; the first link above shows a sample showing how to invoke it using vRO command class.

Reply
0 Kudos
ericr999
Enthusiast
Enthusiast
Jump to solution

ahhh yeah, that would be acceptable for me. Thanks!!

Reply
0 Kudos
ericr999
Enthusiast
Enthusiast
Jump to solution

No way of ignoring certificate errors ? Not a big deal, I'll just have to ask the team to fix their issue with the cerificate of their server.

Also, is there a way to set a custom header ? By looking at the API Explorer, the plugin seems to be limited, and I don't have enough knowledge yet in order to play in a dar file.

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Just to clarify, these questions are about Download plug-in, not HTTP-REST plug-in, correct?

Download plug-in is not developed/supported by vRO team. You may want to ping Joerg directly (he is tschoergez​ here in the forums); he may have a newer version of the plug-in available or be able to suggest some tips/workarounds.

Reply
0 Kudos
ericr999
Enthusiast
Enthusiast
Jump to solution

Hi Ilian,

Yeah, my previous comment was about his plugin. Because the Custom Header works fine with the RESTOperation, but I just can't download a binary file with that plugin. But with the one provided seems to be good, except I can't grab the file needed since its protected by a custom header that acts like a API Key.

I'll send him a message. Thanks!

Reply
0 Kudos