Last active
February 25, 2022 13:46
-
-
Save jakeceballos/24cd89351aa702a0ed174ca693af93ca to your computer and use it in GitHub Desktop.
Mirth Connect - HTTP Request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var body = {} | |
var endpoint = 'https://localhost/'; | |
var method = 'POST'; | |
// Create connection | |
var url = new java.net.URL(endpoint); | |
var conn = url.openConnection(); | |
conn.setDoOutput(true); | |
conn.setDoInput(true); | |
conn.setRequestMethod(method); | |
conn.setRequestProperty("Content-Type", "application/json"); | |
// Send request | |
var outStream = conn.getOutputStream(); | |
var outWriter = new java.io.OutputStreamWriter(outStream); | |
outWriter.write(body); | |
outWriter.close(); | |
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); | |
} | |
respStream.close(); | |
var result = buffer.toString(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jakeceballos yeah, I think you're right. I've ran into an issue with handling on this previous method. It works great otherwise (for my OAuth token generation), but my actual server requests appear to be... well, hard to diagnose issues for.
Trying to use something like below from https://stackoverflow.com/questions/61649942