cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Cannot access timeseries data via REST API getting error: {"error":{"code":400,"message":"The timeframe is missing."}}

eric_schwartz
Newcomer

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

 

5 REPLIES 5

JamesKitson
Dynatrace Leader
Dynatrace Leader

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&relativeTi...

Can refer to examples here:

https://www.dynatrace.com/support/help/dynatrace-a...

James

eric_schwartz
Newcomer

@James K.

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_njoku
Inactive

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

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

surajkumar_pand
Newcomer

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