Gadget Code Snippets

MakeRequest

The makeRequest() callback parameter is passed a javascript object with the following standard fields:

Additionally, several OAuth-specific fields may be returned:

            _clientLogger.log("handleResponse(): The response status code is: " + response.rc);
            _clientLogger.log("response.data :" + response.data);
            _clientLogger.log("response.headers :" + JSON.stringify(response.headers));
            _clientLogger.log ("responseTextJSON: " + JSON.stringify(response.text));

Output

handleResponse(): The response status code is: 200
response.data :{"authToken":"f3ea48e6-006d-4063-8839-00daf1416476"}
response.headers :{"content-type":["application/json; charset=UTF-8"],"content-length":["52"],"server":["Microsoft-HTTPAPI/2.0"],"date":["Sun, 03 May 2020 07:46:52 GMT"]}
responseTextJSON: "{\"authToken\":\"f3ea48e6-006d-4063-8839-00daf1416476\"}"            

Content Type Example

Access the Header Object Property Reference: https://www.w3schools.com/js/js_object_properties.asp

console.log("BLAH*****: "+ response.headers["content-type"]);