Skip to content

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

@chrivand

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

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