Announcement

Collapse
No announcement yet.

API authorization?

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

  • API authorization?

    Ok... I've very new to Mirth, and I'm trying to get started with the API.

    I just want to get a simple list of channels (to start with). I can put "https://localhost:8443/api/channels" into the address bar of a browser, and get the XML response with no problem... but when I try to do it with Postman, I get an "unauthorized" error. Is there some kind of token I need to include? Where would I get it?

    I've tried to first use the "api/users/_login" function, and Mirth gives me a "NullPointerException" and an XML stack trace...

    Is there a correct process?

    Thanks.

  • #2
    Have you searched the forums first? There are other threads on this already.

    After you successfully log in, you'll get a JSESSIONID cookie, which you need to include on all future requests.

    If you're using Postman then I think you need to use a special interceptor plugin to allow cookies to be set in requests. More info on the official Postman site.

    Are you testing with the API documentation page? https://localhost:8443/api/
    Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

    Nicholas Rupley
    Work: 949-237-6069
    Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


    - How do I foo?
    - You just bar.

    Comment


    • #3
      Thanks for the reply! I did a quick search, but didn't see anything right away (a bit impatient I guess). Is there any documentation on the API documentation page about a JSESSIONID cookie? I couldn't find anything.

      Comment


      • #4
        Hmm unfortunately no, it's just more of an HTTP-specific concept. It's rather easy though, all you need to do is include the Cookie header on all future requests, passing in the same thing you get from the Set-Cookie header on the successful login request.

        Make sure to also invoke the logout endpoint after you're finished with a session.
        Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

        Nicholas Rupley
        Work: 949-237-6069
        Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


        - How do I foo?
        - You just bar.

        Comment


        • #5
          Originally posted by narupley View Post
          Make sure to also invoke the logout endpoint after you're finished with a session.
          Will do! Thank again!

          Comment


          • #6
            Ok, I've searched high and low. I'm at wit's end (and if the answer is somewhere in the forums and I've missed it, please point it out. I'll gladly a apologize).

            In Postman, I can log in, and (with intercepter) then perform a GET to api/channels and get a response xml... all good.

            However, from code (jquery) I can log in... and that's about it. I've searched for any info I can get about storing and reusing cookies with many results... none of which have been useful. Can someone just post a simple sample of a login-getchannels-logout method? It can be Jquery, xhr, restsharp... whatever you use.

            Thanks in advance.
            ubm.

            Comment


            • #7
              Bump

              Comment


              • #8
                Functional Code and Write-up for Access Via Powershell

                Old thread, however in my quest to find information regarding accessing the Mirth Connect API this thread kept coming up and it would have helped to have more detailed explanation. My own efforts were to access the API via Powershell and the results can be found here: https://incoherentsysadmin.blogspot....-api-from.html

                Comment

                Working...
                X