Skip to content

umbrella pagination with get request not working - EnforcementGetRequest.py #47

Description

@chrivand

"url_get" variable is not updated correctly in the while loop, causing the next page not to load.

https://github.com/CiscoDevNet/dne-security-code/blob/master/intro-umbrella/EnforcementGetRequest.py

Original code

# keep doing GET requests, until looped through all domains
while True:
    req = requests.get(url_get)
    json_file = req.json()
    for row in json_file["data"]:
        domain_list.append(row["name"])
    # GET requests will only list 200 domains, if more than that, it will request next bulk of 200 domains
    if bool(json_file["meta"]["next"]):
        Url = json_file["meta"]["next"]
    # break out of loop when finished
    else:    
        break

Fixed code

# keep doing GET requests, until looped through all domains
while True:
    req = requests.get(url_get)
    json_file = req.json()
    for row in json_file["data"]:
        domain_list.append(row["name"])
    # GET requests will only list 200 domains, if more than that, it will request next bulk of 200 domains
    if bool(json_file["meta"]["next"]):
        url_get = json_file["meta"]["next"]
    # break out of loop when finished
    else:    
        break

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions