"Unexpected token: <" error thrown
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2022 12:23 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 12:08 AM
Let me know if it is fixed. We are facing the same issue. It will help me out if this is fixed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 02:50 AM
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?