web stats
Unable to send http response status code - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 06-24-2016, 06:47 AM
gojoshi gojoshi is offline
OBX.1 Kenobi
 
Join Date: Jul 2013
Posts: 35
gojoshi is on a distinguished road
Default Unable to send http response status code

Mirth Connect (MC) Version: 3.4.0.8000

I am using a custom response in the post processor that populates a custom response message along with the http status code. The status code example are 404- Not Found, 503-Service Unavailable..etc along with some custom status codes.

The status codes are populated into a variable on the post processor, which is made available throughout the channel via a global channel map. The global channel map is then placed into the “Response Status Code:” field on the source by using the global channel maps velocity variable.

It appears that the “Response Status Code:” field does NOT have access to the response status value generated by the post processor.

I have placed a logger that shows that the correct status code is populated in the status code variable, but MC is not able to transmit the status code.

On the dashboard, when I check the mapping value for the status code variable, it shows that the variable has no value!

My understanding is that the post processor executes at the very end but doesn’t the “Response Status Code:” field have access to the values generated by the post processor?
Is there another way to transmit the http status code?

I have attached a screen shot of the MC source..
Attached Images
File Type: jpg Screen Shot1.JPG (65.9 KB, 67 views)
Reply With Quote
  #2  
Old 06-24-2016, 07:29 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,099
narupley is on a distinguished road
Default

Your syntax is incorrect. You need to use the Velocity-style syntax of ${varName}, not the JavaScript-style of $('varName').
__________________
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
  #3  
Old 06-24-2016, 07:41 AM
gojoshi gojoshi is offline
OBX.1 Kenobi
 
Join Date: Jul 2013
Posts: 35
gojoshi is on a distinguished road
Default

Thanks Nick !!!!!! That worked...

I am using postman to verify the status code, for some reasons I am seeing the status code twice though.. is MC sending custom status codes twice?

Postman screen shot is attached
Attached Images
File Type: jpg Postman.JPG (43.9 KB, 33 views)
Reply With Quote
  #4  
Old 06-24-2016, 07:45 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,099
narupley is on a distinguished road
Default

Sounds like that's an error in your channel code. Check the status of your global channel map variable on the dashboard.

EDIT: Actually no, that may just be how Postman works. It doesn't know what the reason for 299 is, so it just repeats the code.
__________________
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.

Last edited by narupley; 06-24-2016 at 07:47 AM.
Reply With Quote
  #5  
Old 06-24-2016, 08:29 AM
gojoshi gojoshi is offline
OBX.1 Kenobi
 
Join Date: Jul 2013
Posts: 35
gojoshi is on a distinguished road
Default

Could be a postman thing.. it's showing the status code only ONCE for certain codes such as '404'..

The code that I'm using on the MC channel is pretty simple:


var postErrorStatus = '';


if ((message.getConnectorMessages().get(1).getStatus( ) == FILTERED)
&& (message.getConnectorMessages().get(2).getStatus() == FILTERED)
) {
postErrorStatus = '299';
responseMap.put('customResponse',"invalid method .... ");
globalChannelMap.put('postErrorStatus', postErrorStatus);
logger.info("postErrorStatus from global channel map: " + $gc('postErrorStatus'));
}


The logger shows that the status code is populated only once..


Thanks Nick.
Reply With Quote
Reply

Tags
custom response, http, http status, status code

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 10:46 PM.


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