
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2018 12:17 PM
I am new to developing custom widgets and have found some sample code to capture the REST API message response into a variable (responseBody). See the below server script:
(function() { /* populate the 'data' object */ /* e.g., data.table = $sp.getValue('table'); */ try { var r = new sn_ws.RESTMessageV2('Yahoo Finance', 'get');
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode(); }
catch(ex) { var message = ex.getMessage(); } })();
What I would like to do is display the contents of the variable "responseBody" in a page (sc_home) within the service portal. Has anyone done this before?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2018 12:47 PM
Hi,
Simply put that variable as property of Data object, then you can use it in HTML and client script part of the widget.
Server script. After below line
var responseBody = response.getBody();
data.responseBody = responseBody
now on HTML
<pre>{{data.responseBody | json}}</pre>
Hope this helps
Please mark Correct/Helpful if it helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2018 12:47 PM
Hi,
Simply put that variable as property of Data object, then you can use it in HTML and client script part of the widget.
Server script. After below line
var responseBody = response.getBody();
data.responseBody = responseBody
now on HTML
<pre>{{data.responseBody | json}}</pre>
Hope this helps
Please mark Correct/Helpful if it helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2018 12:54 PM
That is to easy. I will give that a try. Thanks for the quick response!