I’m trying to output a JSON result as simply as possible - everything works on the API and it’s returning the correct string, however I cannot seem to get Corvid to display the results as a simple html list and use that to populate an HTML element. I’ve tried other documented methods such as MyApi and MyApiClient but they don’t seem to achieve what I’m trying to do.
Here is my code:
var myObj, i, j, x = "";
myObj = {"size":2,"start":0,"limit":50,"isLastPage":true,"_links":{"self":"https://URL/rest/servicedeskapi/knowledgebase/article?query=test","base":"URL,"context":""},"values":[{"title":"Testing the API","excerpt":"This article was created to test the API and make ","source":{"type":"confluence","pageId":"1007353857","spaceKey":"YKB"},"content":{"iframeSrc":"https://URL/rest/servicedeskapi/knowledgebase/article/view/1007353857"}},{"title":"Testing the second API","excerpt":"I had to create a second test article to check the","source":{"type":"confluence","pageId":"1006698588","spaceKey":"YKB"},"content":{"iframeSrc":"https://URL/rest/servicedeskapi/knowledgebase/article/view/1006698588"}}]}
for (i in myObj.values) {
x += "<b>" + myObj.values[i].title + "</b><br>" + myObj.values[i].excerpt + "<br>" + myObj.values[i].source.pageId + "<p>";
}
$w('#htmlElement).html = x;
The desired result based on the above is example is I want #htmlelement to be populated with:
<b>Testing the API</b><br>This article was created to test the API and make<br>1007353857<p>
<b>Testing the second API</b><br>I had to create a second test article to check the<br>1006698588<p>