<?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 Re: API v2 unexpected output converting curl to Powershell Invoke-RestMethod in Dynatrace API</title>
    <link>https://community.dynatrace.com/t5/Dynatrace-API/API-v2-unexpected-output-converting-curl-to-Powershell-Invoke/m-p/256315#M3387</link>
    <description>&lt;P&gt;&lt;SPAN&gt;(Invoke-RestMethod -Uri "&lt;A href="https://xnm19dypd01/e/52575bc0-1849-4837-8e18-8bc962f4407f/api/v2/metrics/query" target="_blank"&gt;https://xnm19dypd01/e/52575bc0-1849-4837-8e18-8bc962f4407f/api/v2/metrics/query&lt;/A&gt;" -Body $body -Headers $headers).result | ConvertTo-Json&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;$Response.result | ConvertTo-Json&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Converting the result to JSON will get you mostly the same result as your curl output.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Sep 2024 13:59:04 GMT</pubDate>
    <dc:creator>mrandant</dc:creator>
    <dc:date>2024-09-18T13:59:04Z</dc:date>
    <item>
      <title>API v2 unexpected output converting curl to Powershell Invoke-RestMethod</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-API/API-v2-unexpected-output-converting-curl-to-Powershell-Invoke/m-p/254570#M3353</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;
&lt;P&gt;We are attempting to convert the curl command to a powershell Invoke-RestMethod command in the PIA v2 for GET /metrics/query&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am unclear as to why I do not get the data returned with Invoke-RestMethod but CURL works.&lt;/P&gt;
&lt;P&gt;Information is returned, but not the data from the API.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is happening and does anyone see what needs changed to retrieve the data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;Runatyr&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="API_Results.PNG" style="width: 999px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/22110i0E47EB81BF7D048A/image-size/large?v=v2&amp;amp;px=999" role="button" title="API_Results.PNG" alt="API_Results.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Code_Convert.PNG" style="width: 999px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/22111i7F5D3F81A2AA52B2/image-size/large?v=v2&amp;amp;px=999" role="button" title="Code_Convert.PNG" alt="Code_Convert.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P data-unlink="true"&gt;$body = @{&lt;BR /&gt;"metricSelector" = "ext:cloud.azure.microsoft_sql.managedinstances.io_requests"&lt;BR /&gt;"resolution" = "1m"&lt;BR /&gt;"entitySelector" = "type(custom_device),entityName.equals(`"bwc-sqlmi-peachpoc`")"&lt;BR /&gt;}&lt;BR /&gt;$headers = @{&lt;BR /&gt;"accept" = "application/json; charset=utf-8"&lt;BR /&gt;"Authorization" = "Api-Token dt0c01.xxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"&lt;BR /&gt;}&lt;BR /&gt;$response = Invoke-RestMethod -Uri "https://xnm19dypd01/e/52575bc0-1849-4837-8e18-8bc962f4407f/api/v2/metrics/query" -Body $body -Headers $headers&lt;BR /&gt;Invoke-RestMethod -Uri "https://xnm19dypd01/e/52575bc0-1849-4837-8e18-8bc962f4407f/api/v2/metrics/query" -Body $body -Headers $headers&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2024 06:26:33 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-API/API-v2-unexpected-output-converting-curl-to-Powershell-Invoke/m-p/254570#M3353</guid>
      <dc:creator>runatyr</dc:creator>
      <dc:date>2024-09-02T06:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: API v2 unexpected output converting curl to Powershell Invoke-RestMethod</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-API/API-v2-unexpected-output-converting-curl-to-Powershell-Invoke/m-p/255437#M3378</link>
      <description>&lt;P&gt;Update:&lt;/P&gt;&lt;P&gt;I have a PowerShell Script that is using the Invoke-RestMethod.&lt;/P&gt;&lt;P&gt;However, the data returned looks like this in PowerShell.&lt;/P&gt;&lt;P&gt;I don't see the values expected values.&lt;/P&gt;&lt;P&gt;This is what I see.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="runatyr_0-1726053105066.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/22311iF8C63B5AB7FE9B4B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="runatyr_0-1726053105066.png" alt="runatyr_0-1726053105066.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I go about accessing the data in this format?&lt;/P&gt;&lt;P&gt;When I query the API directly with cURL(PowerShell) in the Dynatrace API .. this&amp;nbsp; is the format.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="runatyr_1-1726053198684.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/22312i3F16671269FE4A7B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="runatyr_1-1726053198684.png" alt="runatyr_1-1726053198684.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas how to access the data when returned in that first format using Invoke-RestMethod? and not cURL?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 11:16:02 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-API/API-v2-unexpected-output-converting-curl-to-Powershell-Invoke/m-p/255437#M3378</guid>
      <dc:creator>runatyr</dc:creator>
      <dc:date>2024-09-11T11:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: API v2 unexpected output converting curl to Powershell Invoke-RestMethod</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-API/API-v2-unexpected-output-converting-curl-to-Powershell-Invoke/m-p/256315#M3387</link>
      <description>&lt;P&gt;&lt;SPAN&gt;(Invoke-RestMethod -Uri "&lt;A href="https://xnm19dypd01/e/52575bc0-1849-4837-8e18-8bc962f4407f/api/v2/metrics/query" target="_blank"&gt;https://xnm19dypd01/e/52575bc0-1849-4837-8e18-8bc962f4407f/api/v2/metrics/query&lt;/A&gt;" -Body $body -Headers $headers).result | ConvertTo-Json&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;$Response.result | ConvertTo-Json&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Converting the result to JSON will get you mostly the same result as your curl output.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2024 13:59:04 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-API/API-v2-unexpected-output-converting-curl-to-Powershell-Invoke/m-p/256315#M3387</guid>
      <dc:creator>mrandant</dc:creator>
      <dc:date>2024-09-18T13:59:04Z</dc:date>
    </item>
  </channel>
</rss>

