web stats
Unexpected token error - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 08-19-2019, 09:35 AM
kirbyjwilson kirbyjwilson is offline
OBX.2 Kenobi
 
Join Date: May 2012
Posts: 61
kirbyjwilson is on a distinguished road
Default Unexpected token error

I am receiving this error from the response transformer:

SCRIPT SOURCE: response
SOURCE CODE:
500: }
501: eval('importPackage(' + Packages.java.lang.Class.forName(className).getPac kage().getName() + ')');
502: }
503: }
504: function doScript() {
505: msg = JSON.parse(connectorMessage.getResponseTransformed Data());
506: function doTransform() {
507:
508:
509: if (response.getNewMessageStatus() == 'SENT') {
LINE NUMBER: 505
DETAILS: SyntaxError: Unexpected token: <
Attached Files
File Type: xml TokenChannel.xml (10.5 KB, 1 views)
Reply With Quote
  #2  
Old 08-19-2019, 09:49 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 894
agermano is on a distinguished road
Default

If you look at your actual response data, you're probably getting an HTTP error message instead of the JSON you're expecting.

If you need to be able to handle that gracefully, you'll have to change the inbound type of your response transformer to Raw and manually JSON.parse(msg) after you verify you didn't get an error response.
Reply With Quote
  #3  
Old 08-19-2019, 11:14 AM
kirbyjwilson kirbyjwilson is offline
OBX.2 Kenobi
 
Join Date: May 2012
Posts: 61
kirbyjwilson is on a distinguished road
Default

It seems that I'm unable to get that far - being able to view the response data.

I have this code in the Response Transformer to view it:

var ResponseMessage = response.getMessage();
logger.info("ResponseMessage: "+ ResponseMessage.toString());
var ResponseXML = new XML(ResponseMessage.toString());
logger.info("Response XML=" + ResponseXML.toString());
globalChannelMap.put('RM', ResponseFactory.getSentResponse(ResponseXML));

, but it doesn't get executed because the channel errors out before then:

SOURCE CODE:
500: }
501: eval('importPackage(' + Packages.java.lang.Class.forName(className).getPac kage().getName() + ')');
502: }
503: }
504: function doScript() {
505: msg = JSON.parse(connectorMessage.getResponseTransformed Data());
506: function doTransform() {
507:
508:
509: var ResponseMessage = response.getMessage();
LINE NUMBER: 505
DETAILS: SyntaxError: Unexpected token: <
Reply With Quote
  #4  
Old 08-19-2019, 01:16 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 894
agermano is on a distinguished road
Default

Did you try looking in the message browser? I think it should show up as long as you have your channel's storage set to production or development.

If not, try changing your response transformer's inbound data type to Raw. In that case msg will just be a string, which you should be able to log.
Reply With Quote
  #5  
Old 08-21-2019, 08:48 AM
kirbyjwilson kirbyjwilson is offline
OBX.2 Kenobi
 
Join Date: May 2012
Posts: 61
kirbyjwilson is on a distinguished road
Default

This is the message I received in the message browser:

ERROR: Received error response from HTTP server.

<WSResult>
<Result>
<SessionID>46a7ef52-2fbd-4b8e-ad0a-e3c10989db79</SessionID>
<Code>500</Code>
<Description>INTERNAL_SERVER_ERROR</Description>
<ErrorList count="1">
<Error>Not authorised to view the result
</Error>
</ErrorList>
</Result>
</WSResult>

I accessed the Linux shell on the Mirth Appliance and ran a curl command:

curl -v -X POST -H "Content-Type:application/json" -d '{"UserName":"ABC","Password":"XYZ"}' "https://www.website.com"

I received this:

* Trying 12.34.567.89...
* Connected to www.website.com (12.34.567.89) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@ STRENGTH
* error setting certificate verify locations:
CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* Closing connection 0
curl: (77) error setting certificate veryify locations:
CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none

So it looks like our appliance has a CA certificate issue (I can successfully run the command from another, unrelated UNIX box).
Reply With Quote
Reply

Tags
json, response, token

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 05:30 AM.


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