28 Aug 2024 01:17 PM - edited 28 Aug 2024 01:24 PM
Hello:
We have a 3rd party graphing/dashboard software that wants to present data from the PowerShell
Invoke-Rest Method.
I have successfully used the APIV2 to gather the data in Dynatrace. However, I am running into issues
converting this to use the Invoke Rest Method.
I read several postings here and saw this example of code below.
However, it is not quite do what we want to achieve.
1) I am trying to have the API return the values as text/CSV format.
2) When I attempt this in PowerShell I receive the errors below in the image "Error_Message_Power_Shell_trying_text".
What do I need to change in this script to make it "match" the output from the Dynatrace API v2
An images of the API call is attached.
Below is the script I modified from prior posts in the community.
$Token = 'dt0c01.xxx.xxx'
$Params = @{ "URI" = 'https://xnm19dypd01/e/52575bc0-1849-4837-8e18-8bc962f4407f/api/v2/metrics/query?metricSelector=ext%3...'
"Method" = 'GET'
"Headers" = @{
"Content-Type" = 'text/csv; header=present; charset=utf-8'
"Authorization" = 'Api-Token' + ' ' + $Token
}
}
Invoke-RestMethod @Params | Format-Table
I Think this works if I set the "Content-Type" to "application/json"
(There is no error) However the output data does not match what I see in Dyantrace.
What needs to change in this script to get the data to return in text/CSV format?
Thank you so kindly!