16 May 2018 04:29 PM - last edited on 25 May 2021 02:50 PM 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 05:56 PM - last edited on 29 May 2023 02:45 PM 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
16 May 2018 07:31 PM
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.
16 May 2018 08:08 PM
Hey Eric,
The metric you are looking at does not accept the aggregation parameter. See the doc on that. Please take that out and let me know if it works for you.
Thanks
NJ
17 May 2018 01:49 PM
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
11 Feb 2019 07:16 AM
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