You must create the app within the power bi report on Power BI Service not the desktop. This ensures the PowerBIIntegration.Refresh() function is embedded in the app.
PowerBIIntegration.Refresh()