SyntaxError: Empty JSON string / NativeJSON line

User175049
Mega Guru

Hello,

We've had a workflow on a Service Catalog item successfully execute for some time now. However, I was notified today that the request isn't completing as it should. After researching various logs and workflows, I found an error that appears to be causing this reported issue.  

The error description is "SyntaxError: Empty JSON string (sys_script_include.d2426c9ec0a8016501958bf2ac79c775.script; line 155) "

 

The script include for the sys id listed above is : 

gs.include("PrototypeServer");
 
var JSON = Class.create();
JSON.prototype = {
    indentFlag: false,
    indentLevel: 0,
    INDENT_SPACES: "  ",
 
    initialize: function() {
 
    },
 
    prettify: function() {
        this.indentFlag = true;
        this.indentLevel = 0;
    },
 
    startIndent: function(a) {
        if (this.indentLine(a, true))
            this.indentLevel++;
    },
 
    endIndent: function(a) {
        if (!this.indentFlag)
            return;
 
        this.indentLevel--;
        this.indentLine(a);
    },
 
    indentLine: function(a, skipNewLine) {
        if (!this.indentFlag)
            return false;
 
        if (!skipNewLine)
            a.push("\n");
 
        for (var i = 0; i < this.indentLevel; i++)
            a.push(this.INDENT_SPACES);
 
        return true;
    },
 
    pad: function(n) {
        return n < 10 ? "0" + n : n;
    },
 
    encodeString: function(s) {
        return '"' + GlideStringUtil.escapeNonPrintable(s) + '"';
    },
 
    encodeArray: function(o) {
        var a = [ "[" ];
        this.startIndent(a);
        var b;
        var i;
        var l = o.length;
        var v;
        for ( var i = 0; i < l; i += 1) {
            v = o[i];
            switch (typeof v) {
            case "undefined":
            case "function":
            case "unknown":
                break;
            default:
                if (b) {
                    a.push(',');
                }
                this.indentLine(a);
                a.push(v === null ? "null" : this.encode(v));
                b = true;
            }
        }
        this.endIndent(a);
        a.push("]");
        return a.join("");
    },
 
    getKeys: function(o) {
        var a = [];
        for ( var i in o) {
            a.push(i);
        }
        a.sort();
        return a;
    },
 
    encodeObject: function(o) {
        var a = [ "{" ];
        this.startIndent(a);
        var b;
        var i;
        var v;
        var keys = this.getKeys(o);
        for ( var i = 0; i < keys.length; i++) {
            if (o.hasOwnProperty(keys[i])) {
                v = o[keys[i]];
 
                switch (typeof v) {
                case "undefined":
                case "function":
                case "unknown":
                    break;
                default:
                    if (b) {
                        a.push(',');
                    }
                    this.indentLine(a);
                    a.push(this.encode(keys[i]), ":", v === null ? "null" : this.encode(v));
                    b = true;
                }
            }
        }
 
        this.endIndent(a);
        a.push("}");
        return a.join("");
    },
 
    encodeDate: function(o) {
        return '"' + o.getFullYear() + "-" + this.pad(o.getMonth() + 1) + "-" + this.pad(o.getDate()) + "T"
                + this.pad(o.getHours()) + ":" + this.pad(o.getMinutes()) + ":" + this.pad(o.getSeconds()) + '"';
    },
 
    encode: function(o) {
        if (typeof o == "undefined" || o === null) {
            return "null";
        } else if (o instanceof Array) {
            return this.encodeArray(o);
        } else if (o instanceof Date) {
            return this.encodeDate(o);
        } else if (typeof o == "string" || o instanceof String) {
            return this.encodeString(o);
        } else if (typeof o == "number" || o instanceof Number) {
            return isFinite(o) ? String(o) : "null";
        } else if (typeof o == "boolean" || o instanceof Boolean) {
            return String(o);
        } else {
            return this.encodeObject(o);
        }
    },
 
    decode: function(source) {
        return new SNC.JSONParse().decode(source);
    },
 
    type: "JSON"
};
 
/**
 * Proxies calls to the ES5 JSON object, named NativeJSON in the global scope.
 */
JSON.parse = function(text, reviver) {
return NativeJSON.parse.apply(NativeJSON, arguments);
};
 
/**
 * Proxies calls to the ES5 JSON object, named NativeJSON in the global scope.
 */
JSON.stringify = function(value, replacer, space) {
return NativeJSON.stringify.apply(NativeJSON, arguments);
};

 

 

 

And the line mentioned in the error above (155) is 

return NativeJSON.parse.apply(NativeJSON, arguments);

 

 

 

I am not well versed in JSON.  What is the best way to resolve this error? Is NativeJSON no longer relevant? 

 

I appreciate any insights on this.

Thanks,

m

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@User175049 

that is an OOB script include.

Seems issue is not in the OOB script include.

It's somewhere how you are handling the JSON in the workflow

you need to debug your workflow

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

poojasubhas
Tera Contributor

Hello Ankur, @Ankur Bawiskar 
One catalog item was created in order to automate the process of creating new shared mailboxes in Azure AD from ServiceNow by using spokes.

I am using the create mailbox action from Microsoft Exchange Online spoke in flow. During testing, I receive an above error

 

Some more errors

:

ErrorEncountered error executing instruction: ActionErrorEvalInstruction{id=16, conditions=[], statusKey=c3o.__action_status__, dontTreatAsErrorKey=c3o.__dont_treat_as_error__}, errorMessage:Error: Empty JSON string,Detail: Empty JSON string, errorCode:1
 
ErrorIPaaSActionProbe | Access denied. Script returned status 3 using account user null.
 
ErrorIPaaSActionProbe | Failed to access target system. Please check credentials and firewall settings on the target system to ensure accessibility: Call was canceled by the message filter. (Exception from HRESULT: 0x80010002

 

Failed while executing ExchangeOnlineSpoke-CreateMailbox.ps1

 

I appreciate any insights on this.

Thanks,

 

poojasubhas_0-1718700777480.png

 

 

 

poojasubhas
Tera Contributor

Hello @Ankur Bawiskar 

 

One catalog item was created in order to automate the process of creating new shared mailboxes in Azure AD from ServiceNow by using spokes.

I am using the create mailbox action from Microsoft Exchange Online spoke in flow. During testing, I receive an above error: Error: Empty JSON string, Detail: Empty JSON string.

 

Failed to access target system. Please check credentials and firewall settings on the target system to ensure accessibility: Call was canceled by the message filter. (Exception from HRESULT: 0x80010002 (RPC_E_CALL_CANCELED))

 

Failed while executing ExchangeOnlineSpoke-CreateMailbox.ps1

poojasubhas_0-1718703239862.png

 

I appreciate any insights on this.

Thanks,

 

poojasubhas
Tera Contributor

Hello @Ankur Bawiskar ,

 

I am Facing the same issue while testing the flow.

One catalog item was created in order to automate the process of creating new shared mailboxes in Azure AD from serviceNow by using spokes.

I am using the create mailbox action from Microsoft Exchange Online spoke in flow. 

 

Failed to access target system. Please check credentials and firewall settings on the target system to ensure accessibility: Call was canceled by the message filter. (Exception from HRESULT: 0x80010002 (RPC_E_CALL_CANCELED))

 

Failed while executing ExchangeOnlineSpoke-CreateMailbox.ps1