peya02
(Peya02)
May 25, 2023, 12:42pm
1
Why do I have the following error? How can I define the workshop parameter?
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)
In the last line, workshop appears marked in yellow and the error name ‘workshop’ is not defined appears
milliams
(Matt Williams)
May 25, 2023, 2:50pm
2
A question to help us understand your code, and to help you understand your question: Why do you think that workshop
should be defined on that last line? Where is it being defined, and what value would you expect it to have?
kknechtel
(Karl Knechtel)
May 25, 2023, 5:28pm
3
Where the code says return all_reports(app,workshop)
, what do you expect this to mean? What do you think should be the value of workshop
when this code runs, and why should it have this value - where should it come from?
peya02
(Peya02)
May 26, 2023, 5:09am
4
I have the following function that the workshop brought out
> 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'])
later def all_reports would need that previous workshop to continue, at least that’s what I want.