Web Services (Client) - fdlGitHub/ServiceNow GitHub Wiki

Method GET

Use the following script to perform a Web Service call from a Client Script

var client = new XMLHttpRequest();
client.open("get", "<ENDPOINT>");
client.setRequestHeader('Accept', 'application/json');
client.setRequestHeader('Content-Type', 'application/json');
client.setRequestHeader('X-UserToken', window.g_ck); // Token of the connected user
client.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
        console.info(this.response);
        // Convert the response to a JSON Object
        this.response = JSON.parse(this.response);
    }
};
client.send();
⚠️ **GitHub.com Fallback** ⚠️