No announcement yet.

Converting Curl command to HTTP sender in Mirth Channel (CSV to HTTP Sender) RESOLVED

  • Filter
  • Time
  • Show
Clear All
new posts

  • Converting Curl command to HTTP sender in Mirth Channel (CSV to HTTP Sender) RESOLVED

    So here's my situation. I'm new to Mirth Connect and API in general.

    I'm working on a project where I have 2 Docker containers running:

    - One that runs Mirth Connect
    - One that runs a health information management system

    I'm trying to import data that is in a CSV file to the health information management system by passing it through Mirth Connect (without transforming the data).

    I first tested this locally by using this curl command:

    curl --data-binary @template_import.csv "localhost:8080/api/dataValueSets?dataElementIdScheme=code&orgUnitIdSc heme=code&categoryOptionComboIdScheme=code&dryRun= false&importStrategy=CREATE" -H "Content-Type:application/csv" -u admin:district
    This command worked perfectly fine when running it through my command prompt locally. I could confirm the data was received by the health information system.

    I then tried to reproduce this in a Mirth Connect channel. The source part seems to work fine, however the destination part gives an error (see attached file).

    You'll also find my destination tab configuration attached, and here's how the tab looks in Mirth:
    Note that since I'm using Docker, I created a virtual network and I'm referencing the other container by name instead of IP Address.

    Thanks a lot!​
    Attached Files
    Last edited by pacmano; 06-14-2022, 12:09 PM.

  • #2
    To troubleshoot stuff like this, I would send both requests to your own "dumb" http listener that does not interpret results.

    I use an http-echo-server. If you run a recent version of node.js it is just a one liner:

    npx http-echo-server

    This starts a dumb listener on port 3000 which echoes your request to the terminal session - send your request there and you will see exactly what your curl command sent and what mirth sends.

    It is usually very obvious what is wrong with your mirth channel when you compare the outputs in the console session.
    Last edited by pacmano; 06-07-2022, 07:26 AM.
    Diridium Technologies, Inc.


    • #3
      Thanks for your reply pacmano!

      I'm really new to all this, I'm not familiar with node.js. Could I install a Docker image of it and run that command?

      Sorry, I'm working on this for a school project so I'm still learning.



      • #4
        You can of course likely find some other tool that is just a "dumb" listener which is the main objective here - i.e. to show you the raw http post as received by the other side.

        The echo server I mentioned assumes you have intereactive access to see the output. That is possible of course for a container. There are also containers on docker hub that provide an echo service.

        Diridium Technologies, Inc.


        • #5
          I think there should not be any question mark on the URL.If I remember it would come automatically because you are using query Params.
          HL7v2.7 Certified Control Specialist!


          • #6
            Originally posted by siddharth View Post
            I think there should not be any question mark on the URL.If I remember it would come automatically because you are using query Params.
            Thanks for the tip, however I tried removing it but I still get the same error:

            ERROR: Error connecting to HTTP server [IllegalArgumentException: Host name may not be null]

            I've been trying to figure this out for hours now... it works like a charm if I try the curl command through the terminal, but doesn't seem to work in Mirth... help would be much appreciated! Meanwhile I'm gonna try to figure out the echo server to troubleshoot...


            • #7
              I arleady mentioend to send these to yourself, your calls don't match.

              To get better help:

              Post a full channel export.
              Post a sample dataset to send to the channel.

              Diridium Technologies, Inc.


              • #8
                Yes, I've been trying to figure out how to use an echo server on Docker since yesterday. I don't come from a particularly technical background and am new to Docker and Mirth so I haven't figured it out yet.

                Here's my full channel export.

                Thanks again for the help, much appreciated.
                Attached Files


                • #9
                  Post a sample dataset to send to the channel. I wrote that above.

                  It's a bit hard to help becase we don't know the endpint software that you are calling, can your provide a link to their API specs?
                  Diridium Technologies, Inc.


                  • #10
                    The software is called DHIS2. Here's the API documentation: Data - DHIS2 Documentation
                    dataelement period orgunit categoryoptioncombo attributeoptioncombo value
                    BNBL 2022W10 HOSPITAL default 20-34yF 7
                    Here's the data I'm trying to send (.csv format file).


                    • #11
                      This curl command (note this forum adds spaces in the command):

                      curl --data-binary @template_import.csv "localhost:3000/api/dataValueSets?dataElementIdScheme=code&orgUnitIdSc heme=code&categoryOptionComboIdScheme=code&dryRun= false&importStrategy=CREATE" -H "Content-Type:application/csv" -u admin:district

                      The curl set up:

                      What the other side sees:


                      The mirth setup:

                      1) set your source reader to binary, not text.
                      2) remove the "?" like siddharth said.
                      3) Set pre-emptive

                      What the other side sees:


                      Screenshot of both since font size make it look different:


                      Attached Files
                      Last edited by pacmano; 06-09-2022, 07:05 PM.
                      Diridium Technologies, Inc.


                      • #12
                        Thanks pacmano.

                        I'm still getting the same error for some reason. My channel export after the changes is attached.
                        Attached Files


                        • #13
                          I don’t think you have ever posted the error

                          and I asked you for a sample file which you never posted.

                          You are making it hard to help you
                          Diridium Technologies, Inc.


                          • #14
                            Also the URL hostname of the curl command you posted does not match the channel you posted.
                            Diridium Technologies, Inc.


                            • #15
                              I've attached the error log in my first message, and mentioned it again in my post Special It's the exact same error I'm getting. As for sample file, it is literally a csv file with the data I sent above. I did not attach it as the forum does not allow me to attach a csv file.

                              The URL hostname in the curl command I posted is different because I attempted it locally at first. Since I'm using Docker, I created a virtual network and I'm using the container name as URL instead of IP.

                              If there's anything else you'd like me to provide, feel free to ask. I'm not sure if I'm misunderstanding when you're asking for the error, but I literally provided the log in my first post.