web stats
Access Mirth REST API using Mirth? - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 04-01-2019, 07:13 AM
mdehoog mdehoog is offline
Mirth Guru
 
Join Date: Mar 2011
Location: Apeldoorn the Netherlands
Posts: 289
mdehoog is on a distinguished road
Send a message via Skype™ to mdehoog
Default 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
Reply With Quote
  #2  
Old 04-02-2019, 06:07 AM
mdehoog mdehoog is offline
Mirth Guru
 
Join Date: Mar 2011
Location: Apeldoorn the Netherlands
Posts: 289
mdehoog is on a distinguished road
Send a message via Skype™ to mdehoog
Default 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
Reply With Quote
  #3  
Old 04-02-2019, 06:52 AM
mdehoog mdehoog is offline
Mirth Guru
 
Join Date: Mar 2011
Location: Apeldoorn the Netherlands
Posts: 289
mdehoog is on a distinguished road
Send a message via Skype™ to mdehoog
Default Other post concerning this subject

https://www.mirthcorp.com/community/...d.php?t=216314
__________________
X Connections
https://documentor.email
https://www.x-connections.com
Reply With Quote
  #4  
Old 04-02-2019, 07:28 AM
mdehoog mdehoog is offline
Mirth Guru
 
Join Date: Mar 2011
Location: Apeldoorn the Netherlands
Posts: 289
mdehoog is on a distinguished road
Send a message via Skype™ to mdehoog
Default :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
Reply With Quote
  #5  
Old 04-02-2019, 11:00 PM
obsessio obsessio is offline
OBX.3 Kenobi
 
Join Date: Mar 2015
Location: Turkey
Posts: 164
obsessio is on a distinguished road
Default

Set content type as
PHP Code:
application/x-www-form-urlencoded 
Reply With Quote
  #6  
Old 04-03-2019, 01:04 AM
mdehoog mdehoog is offline
Mirth Guru
 
Join Date: Mar 2011
Location: Apeldoorn the Netherlands
Posts: 289
mdehoog is on a distinguished road
Send a message via Skype™ to mdehoog
Default

No success. Still get the same error.
__________________
X Connections
https://documentor.email
https://www.x-connections.com
Reply With Quote
  #7  
Old 04-03-2019, 01:29 AM
obsessio obsessio is offline
OBX.3 Kenobi
 
Join Date: Mar 2015
Location: Turkey
Posts: 164
obsessio is on a distinguished road
Default

Please share the response now
Reply With Quote
  #8  
Old 04-03-2019, 02:23 AM
mdehoog mdehoog is offline
Mirth Guru
 
Join Date: Mar 2011
Location: Apeldoorn the Netherlands
Posts: 289
mdehoog is on a distinguished road
Send a message via Skype™ to mdehoog
Default 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
File Type: xml Mirth API test safe.xml (165.4 KB, 11 views)
__________________
X Connections
https://documentor.email
https://www.x-connections.com
Reply With Quote
  #9  
Old 04-08-2019, 06:10 AM
obsessio obsessio is offline
OBX.3 Kenobi
 
Join Date: Mar 2015
Location: Turkey
Posts: 164
obsessio is on a distinguished road
Default

Did you find the rigth way to invoke the API with basic auth @mdehoog?
Reply With Quote
  #10  
Old 04-08-2019, 12:52 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 855
agermano is on a distinguished road
Default

Quote:
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.
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 08:31 AM.


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