web stats
Get Token from destination response and pass to new Channel in Mirth - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 10-12-2016, 11:42 PM
user1411 user1411 is offline
What's HL7?
 
Join Date: Oct 2016
Posts: 2
user1411 is on a distinguished road
Question Get Token from destination response and pass to new Channel in Mirth

I've created a channel in Mirth which first calls authentication service and returns response. Source I've configured to HTTP Listener and in destination I've used HTTP Sender which calls a rest service for login and returns token as below.

{"token":"5912aa99-af21-5614-c232-d22be9e5c102","app":"TEST API Suite","expires":845,"userID":"ZCT06D123Cfk20oROB9 x-bEXeY12oQGfack6dMMc-0o="}

Question: From the response that I'm receiving from rest service , how do I extract the token part and then pass that token to another channel and use it for calling another service.

Please Help. I'm a Newbie in Mirth. Thanks.
Reply With Quote
  #2  
Old 10-13-2016, 07:00 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,119
narupley is on a distinguished road
Default

Open up the response transformer and set your response data types to JSON. Post that sample payload in the inbound template, then you can easily create a Mapper step to extract the token and store it in the channel map.

Then you can use a subsequent Channel Writer destination, and in the Message Metadata table include the name of the variable you created.
__________________
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 10-15-2016, 04:26 AM
user1411 user1411 is offline
What's HL7?
 
Join Date: Oct 2016
Posts: 2
user1411 is on a distinguished road
Default

Thanks a lot for your help. I used global variable map for setting that variable. And got that variable in another channel as I wasn't able to figure out how to get/use Message Metadata table
Reply With Quote
  #4  
Old 10-17-2016, 03:46 AM
siddharth siddharth is offline
Mirth Guru
 
Join Date: Feb 2013
Posts: 832
siddharth is on a distinguished road
Default

If you did capture your response in a variable from the response as discussed above, then just drag and drop that variable in the Message Metadata box of the channel writer destination.

It is just above the Template Box. Also has a tool-tip to it.
Reply With Quote
Reply

Tags
json, mirth 3.4.2, webservice

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 01:38 PM.


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