me parece el error NameError: name ‘workshop’ is not defined
código:
def all_reports(app,workshop):
reportes=[]
# print(session)
print(workshop)
for i in workshop:
if i['type'] == 'Workspace':
url=f"https://api.powerbi.com/v1.0/myorg/groups/{i['id']}/reports"
api_response = requests.get(url, headers=get_request_header(app))
if api_response.status_code != 200:
abort(api_response.status_code, description=f'Error while retrieving Embed URL\n{api_response.reason}:\t{api_response.text}\nRequestId:\t{api_response.headers.get("RequestId")}')
api_response = json.loads(api_response.text)
for a in api_response['value']:
dic2={'id_workshop':i['id'],'id_report':a['id'], 'name_report':a['name'] }
reportes.append(dic2)
print(dic2)
@app.route('/allworkshop')
def reporte():
return all_reports(app,workshop)
Donde debo definir el parámetro workshop? el error lo marca en la ultima línea.
Anteriormente a este código ya tengo definida la def get_access_token(app), def get_request_header(app) y def all_workshop2(app)
def all_workshop2(app):
url='https://api.powerbi.com/v1.0/myorg/groups'
api_response = requests.get(url, headers=get_request_header(app))
if api_response.status_code != 200:
abort(api_response.status_code, description=f'Error while retrieving Embed URL\n{api_response.reason}:\t{api_response.text}\nRequestId:\t{api_response.headers.get("RequestId")}')
api_response = json.loads(api_response.text)
print(api_response)
api_response['value']
return (api_response['value'])
En def all_reports(app,workshop) el workshop me vendría dado por el anterior código pero no se como pasarlo.