VMware Cloud Community
jacquesperrin
Enthusiast
Enthusiast

vRO - How to save the result of an HTTP Rest to a binary file (zip)

Hi guys

I'm trying to save the result of an HTTP rest API request to a mime file but the file result is not correct.

I performed a dynamic HTTP request to get the package content:

"vco/api/packages/" + packageName

With header

request.setHeader("Accept-Encoding","gzip, deflate")

request.setHeader("Accept", "application/zip")
request.setHeader("Content-Type", "application/zip;charset=utf-8")

And get the result by the method "contentAsString" of object "RESTResponse",

Then create a mimeFile like :

var mimeAttachment = new MimeAttachment()
mimeAttachment.mimeType = "application/zip"
mimeAttachment.name     = packageName + ".package"
mimeAttachment.content  = response.contentAsString

I suspect that the "contentAsString" method doesn't support this case.



My goal is to export a vRO package to a file by REST API (I know its possible by PowervRO, but I would like to do this without using a windows Powershell host)

Does anybody has already done this task or does exists a another HTTP plugin to perform this task ?

Thanks a lot for your answers

Jacques

Reply
0 Kudos
3 Replies
iiliev
VMware Employee
VMware Employee

Hi,

Handling of binary (not-textual) data is a known pain point in vRO. There could be some clever workarounds for specific use cases, but the real fix should be done in the platform at some point.

I'm not aware of another HTTP plug-in available, and I'm not sure this can be fixed purely on plug-in level.

BTW, currently we have an open support request that is similar to this case. Curious to see what the guys working on it will come up with Smiley Happy

Reply
0 Kudos
lucasmveds
Contributor
Contributor

Hi,

Is there any way to do that with the new version of VRO?

or is there any plugin to handle that?

Thanks

Reply
0 Kudos
htdo
Contributor
Contributor

Better route for you maybe is to use Python, some modification to your code and it would work in Python.

Reply
0 Kudos