Mirth Connect 4.1.1 Released!

Mirth Connect 4.1.1 is now available as an appliance update and on our GitHub page. This release contains modifications to the Welcome to Mirth Connect screen and two fixed defects. See the release notes for the list of fixes and updates.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

Extract zip file from response from "HTTP Sender" GET method

  • Filter
  • Time
  • Show
Clear All
new posts

  • Extract zip file from response from "HTTP Sender" GET method

    Hi all,

    I have to extract a zip file from an API response.

    The description of the response is :
    The format of the HTTP response body is as follow if the status code is 2xx.
    i. Part 1 - header
    1. A Content-type header is “application/zip;charset=UTF-8”.
    2. A Content-disposition header that includes a patient ID and the exact setup time of the corresponding measurement and the format of the corresponded file name is
    an example is as below:
    attachment; filename="";

    i. Part 2 - A report file was encoded Base64 format (my zip file).

    I have an HTTP SENDER (GET Method) and I receive a correct response with status 2xx.

    In the 'Response Transformer', I get the response with : "var myReponse = response.getMessage();"

    My (big) problem is : how could I extract the base64 data from my response ?

    The responseHeader is :
    date=[Tue, 26 Jul 2022 09:19:48 GMT],
    [attachment; filename=""; filename*=utf-8''],

    How can I separate Header from Body of my response ? Any idee ?


  • #2

    In the response transformer, what does msg variable holds.?
    Typically, msg holds the ACK or response coming from the destination. In an HL7 destination it holds the ACK.

    I am guessing in your case, it will hold the entire HTTP response.
    HL7v2.7 Certified Control Specialist!


    • #3
      In other words, what siddharth is saying is that the zipped file is the reponse message (aka "body") content, you don't need to "seperate" it, it is already seperated.
      Diridium Technologies, Inc.


      • #4
        Thank you for yours responses!

        Effectively, "msg" contains my response (zip) and has the same value than "response.getMessage()".

        My problem now is just a problem of CHARSET : i can't unzip the file.
        When I unzip the file, I have an error : "Local : Descriptor UTF8 Descriptor_ERROR " :


        When I do the same with Postman, all is OK ! I can unzip the file.

        I tried to convert to others charset (ISO-8859-x,...) without success!
        In UTF-8 to.

        Any idee ?



        • #5
          Can you share the documentation for the API you are calling?
          Diridium Technologies, Inc.


          • #6
            I don't remember but I think there is an option to select the charset in the HTTP Sender connector.
            HL7v2.7 Certified Control Specialist!


            • #7
              Here is the doc. for the API.
              In the doc, it's the API005.
              In my channel, API001 & API004 are good.

              I'm working in Mirth 4.0.1 on Linux. But my environment is Windows.
              Charset UTF-8 on Linux is it the same than Windows ? (maybe a stupid question?)

              Here a printscreen of my destination : URL is : ""


              To Siddhart, i use content-type "application/json;charset=UTF-8"

              Thank you!
              Attached Files


              • #8
                I've forgot to say that the response of the API is passed to a destination "FileWriter" with method "smb" and the encoding is UTF-8.


                • #9
                  The document says

                  HTTP Media type (content-type): application/x-www-form-urlencoded for calling the API005.

                  HL7v2.7 Certified Control Specialist!


                  • #10
                    You might want to install HTTP traffic monitors, to see if your outgoing request from Mirth is same as what Postman is sending, since as you told it works from Postman.
                    HL7v2.7 Certified Control Specialist!


                    • #11
                      eh, just set up an echo server. those tools on the stackoverflow post are a bit overkill.

                      If you have a recent version of node/npx:

                      npx http-echo-server

                      that fires up a dumb listener on port 3000 that you can send to with mirth and postman.
                      Diridium Technologies, Inc.


                      • #12
                        Hello all,
                        My problem is solved!
                        I have changed the 'Binary MIME Types' from "application/.*(?<!json|xml)$|image/.*|video/.*|audio/.*" to "application/json"!
                        Thank you for your help!