web stats
Regarding REST API - HTTP Sender - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Thread Tools Display Modes
Old 08-11-2016, 12:45 PM
nsinghin nsinghin is offline
Mirth Newb
Join Date: Jun 2012
Posts: 16
nsinghin is on a distinguished road
Default Regarding REST API - HTTP Sender

Hi Nick,

I am trying to consume rest api of VISTA here . There are two options a) writing js code to send the post request for authentication (first step).
b) use the http sender.

Initial issue was that the mirth wont support the https, so i was able to figure that out via stunnel. with that issue resolved next issue I am having with option (a) is that I am getting response code 400 and below is the code for same:

var json = "{\"accessCode\": \"vk1234\",\"verifyCode\": \"vk1234!!\",\"site\": \"9E7A\"}";
var encodedData = java.net.URLEncoder.encode(json, "UTF-8");
//create url
var url = new java.net.URL("");
//open connection to url
var conn = url.openConnection();
conn.setRequestProperty("Content-Type", "application/json");
//Get your output stream
var outStream = conn.getOutputStream();
var outWriter = new java.io.OutputStreamWriter(outStream);

//Now you have to get the response in a stream
var inputStream = conn.getInputStream();
var streamRead = new java.io.inputStreamReader(inputStream);
var resp = new java.io.BufferedReader(streamRead);
////create variable to hold return data
var rData = new java.lang.StringBuffer();
var rDataLine = null;

When working with option (b) i.e. http sender. I was able to make the initial authentication post method call successfully as first destination. But in next destination if I try to call some other method in the API (After getting authenticated) I get the "{"message":"Missing Required Credential","status":400}". So I am stuck getting on both these ways.
Although third option is create a custom jar and use it from custom lib. But I want to leverage what we have in the mirth fully first.
Please let me know your thoughts on both fronts.

Mirth connect v.3.4.1

Nirmal Singh
Reply With Quote
Old 08-12-2016, 06:28 AM
siddharth siddharth is offline
Mirth Guru
Join Date: Feb 2013
Posts: 832
siddharth is on a distinguished road

I don't know about those specific vista APIs. But in general all Web-service APIs follow some protocols. There are some obvious problems with the way you are trying to connect to the API.

For starters, You are not passing Authentication or username/password in the headers. Something like this below. authString can be following basic or digest scheme.

conn.setRequestProperty("Authentication", authString);

Secondly, the APIs shall be returning a session token in response which should be used in the second call.

Before you can calibrate something(method) in Mirth, I would advise using that link you have and play with it first. Try sending requests and check the Developers Console(Chrome F12) for what is the request format being made and response captured.
Reply With Quote

api, http, mirth, rest, vista

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:34 PM.

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