Skip to content

Instantly share code, notes, and snippets.

@jakeceballos
Created April 19, 2018 17:55
Show Gist options
  • Save jakeceballos/f181eeb0eae0a7f14307e5aad866af5d to your computer and use it in GitHub Desktop.
Save jakeceballos/f181eeb0eae0a7f14307e5aad866af5d to your computer and use it in GitHub Desktop.
Mirth Connect - GET request
var url = new java.net.URL('https://api.athenahealth.com/v1/' + practiceId + '/patients?departmentid=' + departmentId + '&limit=' + limit + '&offset=' + offset + '&status=a');
var conn = url.openConnection();
conn.setRequestMethod('GET');
conn.setRequestProperty('Authorization', 'Bearer ' + globalMap.get('Accesstoken'));
var inputStream = conn.getInputStream();
var streamReader = new java.io.InputStreamReader(inputStream);
var respStream = new java.io.BufferedReader(streamReader);
var buffer = new java.lang.StringBuffer();
var line = null;
while ((line = respStream.readLine()) != null) {
buffer.append(line + '\n');
}
respStream.close();
var responseObject = JSON.parse(buffer.toString());
return responseObject;
@mochsner
Copy link

@jakeceballos were you ever able to deal with handling or writing more info in regards to errors ran into here? I've used the same approach, but when server gives a 500 for ANY reason, all we get is a "Wrapped java.io.IOException: Server returned HTTP response code: 500 for URL" that isn't very helpful...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment