"Unexpected token: <" error thrown

Tejal Zete1
Tera Contributor

error is thrown for one of the requests recently.

"Unexpected token: <"

 

In workflow run script we called script include function in that below script we written

SendDataToIIQ: function(User, Domain, Group) {
var errMsg = '';
try {
this.UserID = User;
this.Domain = Domain;
this.Groups = Group;
var r;
if (this.Domain == "Dev.npch.int") {
r = new sn_ws.RESTMessageV2('IIQ-AD-Dev', 'Default Post');
}
if (this.Domain == "Stg.cardinalhealth.net") {
r = new sn_ws.RESTMessageV2('IIQ-AD-Stage', 'Default Post');
}
if (this.Domain == "Appzone.dmz" || this.Domain == "Cardinalhealth.net") {
r = new sn_ws.RESTMessageV2('IIQ-AD-Prod', 'Default Post');
}
var requestBody = '';
requestBody = this.generateJSONPayload(); // To Get Requuest ID and SAM Account
r.setRequestBody(requestBody);
gs.log("SendDataToIIQ - Request Body - " + requestBody, "Cat Item:Access Request for AD Groups");
var response = r.execute();
var responseBody = response.getBody();
gs.log("SendDataToIIQ - Response Body - " + responseBody, "Cat Item:Access Request for AD Groups");
var httpStatus = response.getStatusCode();
var myObj = JSON.parse(responseBody);

if (httpStatus != 200 || myObj.errors != null || myObj.fault != null || myObj.attributes.ValidationErrors != null) {
errMsg = 'HTTP Status: ' + httpStatus;

if (myObj.errors) {
errMsg += ', Errors: ' + myObj.errors + '\nRequest: ' + requestBody;
}
if (myObj.fault) {
errMsg += ', Fault: ' + myObj.fault.detail.errorcode + '\nRequest: ' + requestBody;
}
if (myObj.attributes.ValidationErrors) {
errMsg += ', Validation Error: ' + myObj.attributes.ValidationErrors + '\nRequest: ' + requestBody;
}
return errMsg;
} else {
return ["Success", myObj.attributes.sAMAccountName, myObj.requestID];
}
} catch (ex) {
errMsg = ex.message + '\nRequest: ' + requestBody;
return errMsg;
}
},

 

But in result we are getting  "Unexpected token: <" error

 

2 REPLIES 2

Shashi Yadav3
Tera Explorer

Let me know if it is fixed. We are facing the same issue. It will help me out if this is fixed.

SeanPT
Tera Expert

Hi,

Is the error message ("Unexpected token: <") from the errMsg you are returning? Or is it coming from the exception caught in the catch block? Or is the error something that happens even before errMsg is returned?