Announcement

Collapse
No announcement yet.

Access Mirth REST API using Mirth?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Access Mirth REST API using Mirth?

    I am trying to access the Mirth Client API (https://xxxx.yyyy.zzz:8443/api/) using Mirth HTTP Sender but seem to be stuck with the ssl certificate:

    Code:
    HTTP Sender error
    ERROR MESSAGE: Error connecting to HTTP server
    javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target.
    Has anyone succesfully done this?
    X Connections
    https://documentor.email
    https://www.x-connections.com

  • #2
    One step further. ssl solved.

    I did solve this ssl certificate issue.
    I obtained a free Let_s_Encrypt certificate for a .com domain and installed it in Mirth and in the Java cacert keystore.

    I now can access .https://...../api without any ssl error or warning.

    I now also can access using MC HTTP sender channel the Mirth API via https://xxxxx.yyy:8443/api and get a response as expected. So the home page:

    Code:
    <!DOCTYPE html>
    <html>
    	<head>
    		<meta charset="UTF-8">
    		<title>Mirth Connect Client API</title>
    		<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico" />
    ...................
    But now I need to login, so I enabled in the http sender the Basic Authentiction option. Put in the user and pw, redeployed the channel and tested it.

    No success. I get back :

    Code:
    HTTP Sender error
    ERROR MESSAGE: <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <title>Error 401 Unauthorized</title>
    </head>
    <body><h2>HTTP ERROR 401</h2>
    <p>Problem accessing /api/channels. Reason:
    <pre>    Unauthorized</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.9.v20180320</a><hr/>
    
    </body>
    </html>
    So someting wrong with the authentication.

    Will be continued. Or has anyone an idea?
    X Connections
    https://documentor.email
    https://www.x-connections.com

    Comment


    • #3
      Other post concerning this subject

      https://www.mirthcorp.com/community/...d.php?t=216314
      X Connections
      https://documentor.email
      https://www.x-connections.com

      Comment


      • #4
        :8443/api/users/_login

        So I first need to access this:
        https://xxxxxx.com:8443/api/users/_login.

        But now I get this response:
        Code:
        <html>
        <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
        <title>Error 415 Unsupported Media Type</title>
        </head>
        <body><h2>HTTP ERROR 415</h2>
        <p>Problem accessing /api/users/_login. Reason:
        <pre>    Unsupported Media Type</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.9.v20180320</a><hr/>
        
        </body>
        </html>
        Anyone any ideas????
        X Connections
        https://documentor.email
        https://www.x-connections.com

        Comment


        • #5
          Set content type as
          PHP Code:
          application/x-www-form-urlencoded 

          Comment


          • #6
            No success. Still get the same error.
            X Connections
            https://documentor.email
            https://www.x-connections.com

            Comment


            • #7
              Please share the response now

              Comment


              • #8
                response

                This is sent:
                Code:
                URL: https://mirthapi.com:8443/api/users/_login
                METHOD: POST
                USERNAME: yyyyy
                
                [HEADERS]
                username: yyyyy
                
                [PARAMETERS]
                
                [CONTENT]
                I did play around with Headers, Content

                This is the response:
                Code:
                <html>
                <head>
                <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
                <title>Error 415 Unsupported Media Type</title>
                </head>
                <body><h2>HTTP ERROR 415</h2>
                <p>Problem accessing /api/users/_login. Reason:
                <pre>    Unsupported Media Type</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.9.v20180320</a><hr/>
                
                </body>
                </html>
                I included the channel (without user/pw)
                Attached Files
                X Connections
                https://documentor.email
                https://www.x-connections.com

                Comment


                • #9
                  Did you find the rigth way to invoke the API with basic auth @mdehoog?

                  Comment


                  • #10
                    Originally posted by obsessio View Post
                    Did you find the rigth way to invoke the API with basic auth @mdehoog?
                    You have to check the Preemptive box next to authentication type.

                    Comment


                    • #11
                      Thank you, this is the correct configuration.

                      Originally posted by agermano View Post
                      You have to check the Preemptive box next to authentication type.

                      Comment


                      • #12
                        Preemptive does not help

                        Thanks for the suggestion but the result is still the same.
                        Tried the Preemptive with Basid and Digest but same error:
                        HTML Code:
                        HTTP Sender error
                        ERROR MESSAGE: <html>
                        <head>
                        <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
                        <title>Error 415 Unsupported Media Type</title>
                        </head>
                        <body><h2>HTTP ERROR 415</h2>
                        <p>Problem accessing /api/users/_login. Reason:
                        <pre>    Unsupported Media Type</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.9.v20180320</a><hr/>
                        
                        </body>
                        </html>
                        X Connections
                        https://documentor.email
                        https://www.x-connections.com

                        Comment


                        • #13
                          I attached the channel, please edit user and password.
                          Attached Files

                          Comment


                          • #14
                            Works

                            Thanks. Indeed and so simple.
                            Why complex if it can be simpple too
                            X Connections
                            https://documentor.email
                            https://www.x-connections.com

                            Comment


                            • #15
                              /api/users/_login is working also

                              Got also the https://xxxxx.com:8443/api/users/_login working. Bit different settings. Look at the image.

                              Most important.
                              Content Type: application/x-www-form-urlencoded
                              and the Query Parameters:
                              username & password
                              Attached Files
                              Last edited by mdehoog; 04-11-2019, 04:16 AM.
                              X Connections
                              https://documentor.email
                              https://www.x-connections.com

                              Comment

                              Working...
                              X