Mirth Community

Mirth Community (http://www.mirthcorp.com/community/forums/index.php)
-   Support (http://www.mirthcorp.com/community/forums/forumdisplay.php?f=6)
-   -   API authorization? (http://www.mirthcorp.com/community/forums/showthread.php?t=216350)

UglyBaldMan 08-03-2016 04:20 PM

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.

narupley 08-03-2016 04:24 PM

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/

UglyBaldMan 08-03-2016 04:43 PM

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.

narupley 08-03-2016 04:48 PM

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.

UglyBaldMan 08-04-2016 09:32 AM

Quote:

Originally Posted by narupley (Post 256354)
Make sure to also invoke the logout endpoint after you're finished with a session.

Will do! Thank again! :D

UglyBaldMan 08-05-2016 04:27 PM

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.

UglyBaldMan 08-09-2016 02:34 PM

Bump

it_guy_phx 06-19-2019 08:49 AM

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


All times are GMT -8. The time now is 12:58 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Mirth Corporation