<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Fetching Data from External API - Parse into Table in Dashboarding</title>
    <link>https://community.dynatrace.com/t5/Dashboarding/Fetching-Data-from-External-API-Parse-into-Table/m-p/283842#M5281</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;Due to limitations in Grail currently (from previous post), I'm trying to get data from the Dynatrace API into a dashboard. I am using this code in Dynatrace:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;export default async function () {
  const fake_api_token = 'dtc10.faketoken';
  const response = await fetch('https://api.dynatrace.com/kdsdkeokkdeokfoekfeofko');
  const result = response.json();
  return result;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The query successfully returns but it is all bunched up in the column result. I've tried doing things like result.value and result.data so it auto-formats into a table but it does not.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the Dynatrace Metrics Query V2 from the API and have been following this article:&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.dynatrace.com/docs/analyze-explore-automate/dashboards-and-notebooks/dashboards-new/components/dashboard-component-code" target="_blank"&gt;Add code to a dashboard — Dynatrace Docs&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 14 Aug 2025 14:50:52 GMT</pubDate>
    <dc:creator>badgerfifteen</dc:creator>
    <dc:date>2025-08-14T14:50:52Z</dc:date>
    <item>
      <title>Fetching Data from External API - Parse into Table</title>
      <link>https://community.dynatrace.com/t5/Dashboarding/Fetching-Data-from-External-API-Parse-into-Table/m-p/283842#M5281</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;Due to limitations in Grail currently (from previous post), I'm trying to get data from the Dynatrace API into a dashboard. I am using this code in Dynatrace:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;export default async function () {
  const fake_api_token = 'dtc10.faketoken';
  const response = await fetch('https://api.dynatrace.com/kdsdkeokkdeokfoekfeofko');
  const result = response.json();
  return result;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The query successfully returns but it is all bunched up in the column result. I've tried doing things like result.value and result.data so it auto-formats into a table but it does not.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the Dynatrace Metrics Query V2 from the API and have been following this article:&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.dynatrace.com/docs/analyze-explore-automate/dashboards-and-notebooks/dashboards-new/components/dashboard-component-code" target="_blank"&gt;Add code to a dashboard — Dynatrace Docs&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Aug 2025 14:50:52 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dashboarding/Fetching-Data-from-External-API-Parse-into-Table/m-p/283842#M5281</guid>
      <dc:creator>badgerfifteen</dc:creator>
      <dc:date>2025-08-14T14:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: Fetching Data from External API - Parse into Table</title>
      <link>https://community.dynatrace.com/t5/Dashboarding/Fetching-Data-from-External-API-Parse-into-Table/m-p/284797#M5341</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I tested the code you sent, and I changed it to extract the SLOs using the Dynatrace API and you’re right—it returns a table with the API results, and one column contains the information (in my case, it’s called “slo”) when using "return result", as shown below:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Code:&lt;/EM&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;export default async function () {
  const token = 'dt0c01.token';
  const response = await fetch('https://dynatrace.com/e/8436fe7/api/v2/slo', {
  headers: {
    Accept: "application/json",
    Authorization: "Api-Token " + token
  }});
  const result = response.json();

  return result;
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;EM&gt;Result:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="luis_alcantara_0-1756218362798.png" style="width: 999px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/29842i3106BBA9901C5E69/image-size/large?v=v2&amp;amp;px=999" role="button" title="luis_alcantara_0-1756218362798.png" alt="luis_alcantara_0-1756218362798.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If we try to use return "result.slo", it shows that there’s no data:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Code:&lt;/EM&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;export default async function () {
  const token = 'dt0c01.token';
  const response = await fetch('https://dynatrace.com/e/8436fe7/api/v2/slo', {
  headers: {
    Accept: "application/json",
    Authorization: "Api-Token " + token
  }});
  const result = response.json();

  return result.slo;
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;EM&gt;Result:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="luis_alcantara_1-1756218615980.png" style="width: 999px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/29846i57CDE0DF218F24C2/image-size/large?v=v2&amp;amp;px=999" role="button" title="luis_alcantara_1-1756218615980.png" alt="luis_alcantara_1-1756218615980.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So, I then tried adding "await" to "const result = response.json();", making it "const result = await response.json();", and that did return the table with the SLOs. Just to clarify, I added the headers because the API call requires authorization:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Code:&lt;/EM&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;export default async function () {
  const token = 'dt0c01.token';
  const response = await fetch('https://dynatrace.com/e/8436fe7/api/v2/slo', {
  headers: {
    Accept: "application/json",
    Authorization: "Api-Token " + token
  }});
  const result = await response.json();

  return result.slo;
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;EM&gt;Result:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="luis_alcantara_3-1756218814467.png" style="width: 999px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/29850i99C8EA10C334AAC7/image-size/large?v=v2&amp;amp;px=999" role="button" title="luis_alcantara_3-1756218814467.png" alt="luis_alcantara_3-1756218814467.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I’m not sure if this answers your question, but if you have any other doubts, please feel free to ask.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Aug 2025 14:35:24 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dashboarding/Fetching-Data-from-External-API-Parse-into-Table/m-p/284797#M5341</guid>
      <dc:creator>luis_alcantara</dc:creator>
      <dc:date>2025-08-26T14:35:24Z</dc:date>
    </item>
  </channel>
</rss>

