16 May 2018
08:29 AM
- last edited on
25 May 2021
06:50 AM
by
MaciejNeumann
I am trying to access time series data using Powershell:
$Uri = "https://<my_tenant>.live.dynatrace.com/api/v1/timeseries?timeseriesId=com.dynatrace.builtin:host.availability?relativeTime=hour?queryMode=total?aggregationType=avg"
$headers = @{}
$headers.Add("Authorization", "<my tenant token")
$headers.Add("Content-Type", "application/json")
$headers.Add("Method", "POST")
Invoke-RestMethod -Headers $headers $Uri
I get this error: Invoke-RestMethod : {"error":{"code":400,"message":"The timeframe is missing."}}
I know it isn't an authorization issue since I can get other API URLs to work such as: "https://<my_tenant>.live.dynatrace.com/api/v1/entity/infrastructure/hosts"
and "https://<my_tenant>.live.dynatrace.com/api/v1/timeseries" without any parameters.
timeframe is also obviously in the URL :relativeTime=hour
(I have tried week and day also with the same error)
Thanks,
Eric
Solved! Go to Solution.
16 May 2018
09:56 AM
- last edited on
29 May 2023
06:45 AM
by
MaciejNeumann
You have question marks between your parameters, I think you want ampersands '&'. Like this:
https:// . live.dynatrace.com/api/v1/timeseries?timeseriesId=com.dynatrace.builtin:host.availability&relativeTime=hour&queryMode=total&aggregationType=avg
Can refer to examples here:
https://www.dynatrace.com/support/help/dynatrace-a...
James
I got the same error when I changed the '?' to '&'.
I also tried providing startTimestap and endTimestamp instead of relativeTime, still received the same error.
NJ,
I got it to work by moving all of the needed URL parameters to a $Body variable and including that in the method Invocation: Invoke-RestMethod -Headers $headers $Uri -Body $Body
I was still getting the same error of ,"The timeframe is missing." after I removed the aggregation and mode parameters. Thank you for the advice, it sent me down the right path to get it to work.
Eric
I am getting simmilar error for the timeseries API. Could you please help how to resolve this. I am trying the below URL.
curl -H "Content-Type: application/json" -k --insecure -H "Authorization: Api-Token xxxxxxxxx" -X GET https://MyHost/e/8f1b215f-79f1-4a9d-b76a-25da9ce3394f/api/v1/timeseries/com.dynatrace.builtin:service.responsetime?includeData=true&relativeTime=hour&aggregationType=avg&entity=SERVICE