I have a GET request of an API that displays 100 items per page. After reading those 100 items the script calls the API for the next page and so on. However, the link for the following page expires after a while and the script stops midway. Is there a way to make the link available for more time? Or would an async. call help me?
I am using python, and the request looks like this:
def write_RTC_Json_to_Array(self):
toContinue = True
data = []
while toContinue:
json_data = json.loads(self.result)
status = ""
planned_release = ""
try:
page_total = len(json_data["oslc_cm:results"])
except KeyError:
# Handle the error or assign a default value to page_total
page_total = 0
for i in range(page_total):
trs_ids = []
CR = json_data["oslc_cm:results"][i]
tempArray = []
for attribute_name in self.attributes:
if attribute_name == "dc:identifier":
//attributes retrieval
data.append(tempArray)
self.no_urls += 1
if "oslc_cm:next" in json_data:
next_str = json_data["oslc_cm:next"]
string1 = next_str.split("rtc_cm:results")[0]
string2 = next_str.split("rtc_cm:results")[1]
final_url = string1 + "rtc_cm:results.json" + string2
self.set_url(final_url)
else:
toContinue = False
self.set_data(data)