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

PowerBI automate generation of nextPageKey

Frequent Guest

Hi, I am trying to use the Dynatrace API to import data into PowerBI and some metrics have a limited number of results per page and using the nextPageKey to get the next pages of the API request.

My question is, how can we automate the generation of these keys? I have seen a few posts suggest using Postman scripts but that does not seem to work for me. Any idea on how I can do this? I am flexible with any tool whether it be PowerBI itself or Postman, just want to be able to this properly.




If you will select less interval (time frame) and the data will be less than page limit - you don't need to worry about next page key.
E.g. -1w has 5 pages
-1d has 1 page
make 7 requests in the loop to get all data...
or yes - use script to iterate page keys

Our team is looking to work with data that covers an entire month therefore our pages are generally quite a lot. I have tried to use a Postman script but after the first time of it working now it does not read the nextPageKey as a variable and passes an error.

The error is a TypeError: Cannot read properties of undefined (reading 'nextPageKey')

Dynatrace Enthusiast
Dynatrace Enthusiast


from my experience the best way is to extract the data that you need first using a script and then ingest it to PowerBI.
Below you have a method that can be used to get all the problems in your environment:

def getProblems():
    problems_list = []
    url = ROOT_URL + '/api/v2/problems'
    parameters = {
        'pageSize': 500,
        'from': 'now-90d'
    res = requests.get(url, headers=HEADER, verify=False, params=parameters)
    json_data = json.loads(res.text)
    while "nextPageKey" in json_data:
        parameters = {"nextPageKey": json_data["nextPageKey"]}
        res = requests.get(url=url, headers=HEADER, params
        =parameters, verify=False)
        json_data = json.loads(res.text)

    return problems_list

Featured Posts