Announcement

Collapse
No announcement yet.

HTTP Sender body response when 4XX

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • HTTP Sender body response when 4XX

    Hello everyone, there is a third party who needs to receive hl7 messages over a HTTP endpoint. So I am using the HTTP Sender to send message. I am using Mirth 3.8.1, fedora 31 and open jdk 11 from adopt an openjdk

    We are sending patient creation messages. But there are many times, the patients are duplicated.

    If the patient is really new. They respond with a 201 http created code. Every thing is perfect and works ok.

    But if the patient is a duplicate. They respond with a 422 http Unprocessable Entity and a human readable text in the HTTP body response.

    Mirth detects 422 as an error, so it begins to queue, resend, timeouts ... all the stuff.

    As 422 is not really an error, I have the following code in my response transformer

    Code:
    // if there is a 422 error, it is OK, I change the status to SENT
    if( Packages.org.apache.commons.lang3.StringUtils.contains(${'responseStatusLine', '422') )
    	responseStatus = SENT;
    This does the trick, everything works great. But I am still unable to the get the response body with the explanation of the error they send.

    Code:
    response.getMessage(); // It gets nothing
    The upper code only retrieves the response body if there is a 2XX response, not a 4XX. I have checked in postman there is one. But I am not able to get it in Mirth

    To sum up, I have the following questions
    • Is there a way to configure to ignore 4XX errors, so there is no need to do the responseStatus = SENT ?
    • Is there a way to retrieve the body response when the status code is a 4XX ?


    Changing the third party API/responses, or checking for duplicates before sending the message is not possible.

    Thank you very much in advance. Any idea is really wellcome.

  • #2
    I have to say I am really sorry.

    Code:
    response.getMessage();
    It gets the body response no matter the http status code. I may have messed with the logger statements.


    So there is only one question left
    • Is there a way to configure to ignore 4XX errors, so there is no need to do the responseStatus = SENT ?


    Thank you very much in advance.

    Comment


    • #3
      https://github.com/nextgenhealthcare...cher.java#L393

      It's hard coded into the connector that any status code < 400 is SENT, otherwise it's QUEUED, so I think the response transformer is your only option.

      Comment

      Working...
      X