I am trying to insert network ID's, which are located on a per line basis in a text document. There are about 500 lines of ID's. For each network ID, I need to insert it into an existing URL. The function of this is to query the names of network names associated with the ID in Meraki.
I am not fluent in python but here is what I have so far. Where the %s is located, that is where I need each network from the text file inserted into the URL. This one runs, but only returns the very last line in the text document.
import requests, meraki, json, os
with open('Test.txt') as file1:
file = file1.readlines()
for line in file:
url = 'https://dashboard.meraki.com/api/v0/networks/%s' %line.rstrip("\n")
payload = None
headers = {'X-Cisco-Meraki-API-Key': 'API_Key','Content-Type': "application/json"}
response = requests.request('GET', url, headers = headers, data = payload, allow_redirects=True, timeout = 10)
print(response.text)
Thank you.