Forum Discussion
Power BI Server and REST calls by angular app
- Anonymous7 years ago
The simplest of the PBIRS API calls is as shown in the screenshot.
Here is the code if you want to invoke the same API call using PowerShell
$Cred = Get-Credential
$Url = "http://powerbi.local/Reports/api/v2.0/Me"
#Invoke-RestMethod -Method 'GET' -Uri $Url -UseDefaultCredentials -OutVariable UserContext
Invoke-RestMethod -Method 'GET' -Uri $Url -Credential $Cred -OutVariable UserContext
echo $UserContextHere is the list of PBI RS APIs that you can play with.
Please accept the solution, if you agree.
Cheers,
Hari T
- Anonymous7 years ago
You can set your cedentials at the GET request level by choosing the Authorization method as "NTLM Authentication".
This is when you are on windows and using Windows Authentication. You can also set the Domain of your Org. in the advanced properties.
Cheers,
Hari T
Can you give me an example please?
The simplest of the PBIRS API calls is as shown in the screenshot.
Here is the code if you want to invoke the same API call using PowerShell
$Cred = Get-Credential
$Url = "http://powerbi.local/Reports/api/v2.0/Me"
#Invoke-RestMethod -Method 'GET' -Uri $Url -UseDefaultCredentials -OutVariable UserContext
Invoke-RestMethod -Method 'GET' -Uri $Url -Credential $Cred -OutVariable UserContext
echo $UserContext
Here is the list of PBI RS APIs that you can play with.
Please accept the solution, if you agree.
Cheers,
Hari T
- sato897 years agoHelper IThank you! Great!!! Last question: what is the ID in the body and where I can find it? Is it the ID of my report? On PBI report server I cannot find it!
- Anonymous7 years agoNot applicable
The GET call in my example returns the User Context properties.
To answer your question, it is the UserID which is stored as GUID in ReportServer metadata.
Cheers,
Hari T
- sato897 years agoHelper I
Hi Harikishant. Thank you.
I want to accept your answer as a solution, but there is still something missing!
Are you speaking about the "UserID field in "Users" table into the PBI Server database?
However, in my case, I receive "401 Unauthorize".
I sent a GET request with Postman to PBI Server WebPortal URL and WebService URL without body and with only "Content-Type"="application/json" as Header.
My question is: where should I set the credentials before send the request to obtain the authorization?
Many thanks.
- deepchourasiya4 years agoFrequent Visitor
Hey Anonymous, I'm trying to call Power BI to rest APIs from an Angular Application using HTTP get request, also passing all the required params and the Auth token through the request header but getting 304 forbidden error in response.
The strange thing is the same request is working through the Postman with the same request header and params.
I'm not sure what causing this issue...