Gadget Code Snippets

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

  • "data" - Parsed data of the response, if applicable. This will contain a different type of data depending on the type of request that was made. See the a:ContentType parameters for information about what to expect in this field. The raw response text is returned if the response could not be parsed.
  • "errors" - This will contain an array of any errors that occurred when making this request. For example, if a 500 error occurred in the request: "500 error"
  • "headers" - An object containing the response headers. Header names are used as the keys for this object.
  • "rc" - This is a numeric value representing the HTTP status code of the response.
  • "text" - This will return the unparsed text of the response.

Additionally, several OAuth-specific fields may be returned:

  • "oauthApprovalUrl" - If this value is specified, the user needs to visit an external page to approve the gadget's request to access data. Use of a pop-up window to direct the user to the external page is recommended. Once the user has approved access, the gadget can repeat the makeRequest call to retrieve the data.
  • "oauthError" - If this value is specified, it indicates an OAuth-related error occurred. The value will be one of a set of string constants that can be used for programmatically detecting errors. The constants are undefined for opensocial-0.8, but implementers should attempt to agree on a set of useful constant values for standardization in opensocial-0.9.
  • "oauthErrorText" - If this value is specified, it indicates an OAuth-related error occurred. The value is free-form text that can be used to provide debugging information for gadget developers.

            _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"]);
  • vendors/cisco/uc/ucce/finesse/gadgetcodesnippets.txt
  • Last modified: 2024/09/30 17:19
  • by gerardorourke