VMware Aria Automation Orchestrator

 View Only
  • 1.  vRO - How to save the result of an HTTP Rest to a binary file (zip)

    Posted Apr 02, 2019 01:13 PM

    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



  • 2.  RE: vRO - How to save the result of an HTTP Rest to a binary file (zip)

    Broadcom Employee
    Posted Apr 02, 2019 06:32 PM

    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 :smileyhappy:



  • 3.  RE: vRO - How to save the result of an HTTP Rest to a binary file (zip)

    Posted Jun 07, 2022 01:23 PM

    Hi,

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

    or is there any plugin to handle that?

    Thanks



  • 4.  RE: vRO - How to save the result of an HTTP Rest to a binary file (zip)

    Posted Mar 03, 2025 10:04 AM

    Hi Ilian Iliev,

    I know it's an old post but maybe you remember about the "open support request"? How did it end?

    I also encounter issue in trying to "download" a zip file with vRO HTTP rest when I'm trying to download Usage Insight reports from https://console.cloud.vmware.com

    This is how my request looks like:
    var request = transientHost.createRequest("GET", urlRef, null);
    request.setHeader("Authorization", "Bearer " + accessToken);
    request.setHeader("Accept", "text/tab-separated-values+zip");
    request.setHeader("Accept-Encoding", "gzip, deflate, br, zstd");
    request.setHeader("Content-Type", "text/tab-separated-values+zip");

    Thanks!




  • 5.  RE: vRO - How to save the result of an HTTP Rest to a binary file (zip)

    Posted Mar 04, 2025 12:42 AM

    Just did a blog post on this, a month ago: https://kuklis.github.io/cma/post/vro8-http-binary-files/




  • 6.  RE: vRO - How to save the result of an HTTP Rest to a binary file (zip)

    Posted Mar 04, 2025 12:54 AM

    Dear xian,

    I hope you are fine.

    Thank you very much for sharing your blog post!!!

    Best regards

    Antonio




  • 7.  RE: vRO - How to save the result of an HTTP Rest to a binary file (zip)

    Posted Mar 04, 2025 01:05 AM

    Hi xian,

    Thanks for the blog post. It really help by using Python as an workaround if you have the license to allows using Python on vRO.

    I'll be more than happy if VMware will add some new features to the HTTP Rest plugin also. :)

    Thanks again for help!




  • 8.  RE: vRO - How to save the result of an HTTP Rest to a binary file (zip)

    Posted Jul 22, 2022 01:56 PM

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



  • 9.  RE: vRO - How to save the result of an HTTP Rest to a binary file (zip)

    Posted Mar 04, 2025 12:33 AM

    Hi @ririmia,

    I hope you are fine.

    I also faced a similar challenge, and what I did was following the advice @htdo shared with you: using Python. A very basic code is listed below:

    ...
    donwload_response = {'base64_encoded_string':'', 'error_status_code':''}
            try:
                response = requests.post(url, headers=headers, params=parameters, json=payload)
                
                # Raise an exception for bad status codes (4xx and 5xx)
                response.raise_for_status()
    
                print ('response.status_code: ', response.status_code)
                binary_data = response.content
    
                # Convert the binary data to base64
                base64_encoded_data = base64.b64encode(binary_data)
    
                # Convert from bytes to a string (if needed)
                base64_encoded_string = base64_encoded_data.decode('utf-8')
    
                donwload_response['base64_encoded_string'] = base64_encoded_string
    
    ...

    I was able to receive a binary file and then convert it to base64, maybe this could help you.

    Best regards

    Antonio




  • 10.  RE: vRO - How to save the result of an HTTP Rest to a binary file (zip)

    Posted Mar 04, 2025 01:06 AM

    Hi antonioaraujo,

    Thanks for your solution!  I'll take a look at Python as an alternative.