Use the python tool for ease, since you didn't say much about the API you'll be calling, here is a vague example. If you have would have said like Azure Storage or like Jira then I can provide a script for that. In python, you'll be able to create all the loops you so desire.
--------------------------------------------
import requests
import pandas as pd
# Initial Input: URL and body
initial_body = {"key": "value"} # Replace with your initial body (in JSON or text format)
# Create a list to store results
results = []
# Loop to make HTTP requests
current_body = initial_body
while True:
# Make the HTTP request
response = requests.post(url, json=current_body)
# Check if the request was successful
if response.status_code != 200:
print(f"Request failed with status code: {response.status_code}")
break
# Parse the response data (assuming JSON format)
result = response.json()
if not result: # Exit loop if the result is empty
break
# Store the result
results.append(result)
# Update the current_body with the last row's body value from the result
# Assuming result is a list of dictionaries and "body" is the field to update
current_body = result[-1].get("body", {})
# Convert results to a pandas DataFrame (if needed)
results_df = pd.DataFrame(results)
# Output the results (to Alteryx or save to file)
print("Results:", results_df)