web stats
How to handle an ACK from an HTTP POST using the HTTP Sender? - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Thread Tools Display Modes
Old 04-11-2017, 08:00 AM
bluebird bluebird is offline
What's HL7?
Join Date: Apr 2017
Posts: 1
bluebird is on a distinguished road
Default How to handle an ACK from an HTTP POST using the HTTP Sender?


I've searched the forums and have not figured out what I need. I want to POST an HL7v2 message as a string using the HTTP Sender. (i.e. as a simple form field. Not a SOAP request or anything like that.) What should be the response of this POST in case there's an error or in case it is successful? When sending via MLLP the MLLP listener can respond with an ACK, but I'm not sure exactly what the response to an HTTP POST should look like?

Based on reading other posts to the forums it seems Mirth would need to use a "response transformer". Is this correct? Does this mean the response could be e.g. just an HL7v2 ACK message in the body of the HTTP response? Is there a convention or best practice for this sort of thing?

Reply With Quote
Old 04-11-2017, 08:33 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road

Since you've cross-posted on both here and SO, I'll just copy my answer from there.

The short answer is that it's completely up to you... Mirth Connect can accommodate any response (or lack thereof) and perform custom user-logic to decide whether the response is "successful" or not.

You could have your external web service generate an HL7 v2.x ACK and send that back. Then on the HTTP Sender side, make sure your Response data types are set to HL7 v2.x, and enable "Validate Response" in the destination settings.

You can also have your web service generate a completely custom response and do custom validation on the MC side. For example if you have your web service send back a response like this:

    "success": true,
    "message": "Message received successfully."
Then you can set your Response data types to JSON, and do this in the response transformer:

if (msg.success !== true) {
    responseStatus = ERROR;
responseStatusMessage = msg.message;
You can also validate purely on the response status code. By default with an HTTP Sender, the message status will be set to SENT only if the HTTP request returned with a status of < 400. Anything else and the status will be left as QUEUED (or ERROR if queuing is disabled).

You can override that behavior in the response transformer though. Maybe you only want it to be SENT if the status is specifically 200 (and not other 2xx or 3xx codes). Set your Response data types to Raw (so that the response transformer will execute even when there is no response), and do this in the response transformer:

var responseStatusLine = $('responseStatusLine');
var responseCode = parseInt(responseStatusLine.split(' ')[1], 10);
if (responseCode != 200) {
    responseStatus = ERROR;
    responseStatusMessage = responseStatusLine.substr(responseStatusLine.indexOf(' ')).trim();
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
Old 06-21-2018, 05:04 AM
thehemantgupta thehemantgupta is offline
What's HL7?
Join Date: Jun 2018
Posts: 2
thehemantgupta is on a distinguished road
Default Mirth response

I am using mirth to sent data in some API. I have successfully send data to the API and also get response. As above you have mentioned code for to get response but I got stuck where to put these code either in destination transformer or in source transformer. I also want to store this response in my local system.
Hemant Gupta
Reply With Quote

ack, http sender

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 09:51 AM.

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