web stats
API authorization? - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 08-03-2016, 03:20 PM
UglyBaldMan UglyBaldMan is offline
What's HL7?
 
Join Date: Aug 2016
Posts: 5
UglyBaldMan is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 08-03-2016, 03:24 PM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

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.
Reply With Quote
  #3  
Old 08-03-2016, 03:43 PM
UglyBaldMan UglyBaldMan is offline
What's HL7?
 
Join Date: Aug 2016
Posts: 5
UglyBaldMan is on a distinguished road
Default

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.
Reply With Quote
  #4  
Old 08-03-2016, 03:48 PM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

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.
Reply With Quote
  #5  
Old 08-04-2016, 08:32 AM
UglyBaldMan UglyBaldMan is offline
What's HL7?
 
Join Date: Aug 2016
Posts: 5
UglyBaldMan is on a distinguished road
Default

Quote:
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!
Reply With Quote
  #6  
Old 08-05-2016, 03:27 PM
UglyBaldMan UglyBaldMan is offline
What's HL7?
 
Join Date: Aug 2016
Posts: 5
UglyBaldMan is on a distinguished road
Default

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.
Reply With Quote
  #7  
Old 08-09-2016, 01:34 PM
UglyBaldMan UglyBaldMan is offline
What's HL7?
 
Join Date: Aug 2016
Posts: 5
UglyBaldMan is on a distinguished road
Default

Bump
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 01:24 AM.


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