Forum Discussion
Connect to Business Object Webi report through RESTful request
- 9 years ago
Continuing my previous post:
2 issues arise when I upload to Power BI service and try to refresh through the data gateway:
1) functions are not accepted - fixed easily by adding the logon function within the main query as a subquery
2) the main query credential (anonymous) isn't accepted by Power BI services - fixed by using relativepath in my webcontent()
Also I have added to my query a first subquery to retrieve the report ID of the latest instance of the report stored in Business Object.
If anyone is interested to see the details I am happy to share my query.
Replying to myself:
I used this thread to send a POST call to SAP BO.
My GetToken() function in powerquery looks like this:
let
Source = () => let
body = Text.ToBinary("<attrs>
<attr name=""userName"" type=""string""><username></attr>
<attr name=""password"" type=""string""><password></attr>
<attr name=""auth"" type=""string"" possibilities=""secEnterprise,secLDAP,secWinAD,secSAPR3"">secWinAD</attr>
</attrs>"),
actualUrl = "baseurl",
options = [
Headers =[#"Content-type"="application/xml",#"Accept"="application/json"],
Content=body
],
result = Web.Contents(actualUrl, options),
#"Imported JSON" = Json.Document(result,1252),
logonToken = #"Imported JSON"[logonToken]
in
logonToken
in
Source
- Gautier9 years agoFrequent Visitor
Continuing my previous post:
2 issues arise when I upload to Power BI service and try to refresh through the data gateway:
1) functions are not accepted - fixed easily by adding the logon function within the main query as a subquery
2) the main query credential (anonymous) isn't accepted by Power BI services - fixed by using relativepath in my webcontent()
Also I have added to my query a first subquery to retrieve the report ID of the latest instance of the report stored in Business Object.
If anyone is interested to see the details I am happy to share my query.
- Anonymous9 years agoNot applicable
Hi can you give me some more details.
When I pass this for logging into the system
Logon: POST
http://SERVERapp01.ORGnet.org:6405/biprws/logon/long
Now it is returning just the attributes and I am unable to pass the username/password to retreive the report content.
I even tried by using my report URL
http://SERVERapp01.ORGnet.org:6405/biprws/raylight/v1/documents/7555555/reports/5
Did you sucessfully get back the report content if so please guide me here.
What am I missing.
- Gautier9 years agoFrequent Visitor
Hi,
you need to post the logon string as a POST call (not GET).
To do that you need to use the Web.Content() with the content option (adding a content option to webcontent transforms the WebContent call into a POST call).
Also you need to have the logon string as a binary using the Text.ToBinary() function.
Username and password need to be hard coded in the xml logon string. Just replace the red text of the below xml code with your username, password and authentication type.
"<attrs>
<attr name=""userName"" type=""string""><username></attr>
<attr name=""password"" type=""string""><password></attr>
<attr name=""auth"" type=""string"" possibilities=""secEnterprise,secLDAP,secWinAD,secSAPR3"">secWinAD</attr>
</attrs>"Look at my first post to see the complete query I used to get the logon token back from logon API.
To export the report content I used the following function:
Export latest instance as CSV = Web.Contents(baseUrl,[ Headers =[#"Content-type"="application/xml",#"X-SAP-LogonToken"=token,#"Accept"="text/csv"], RelativePath="raylight/v1/documents/"&#"Latest Instance ID"&"/reports/"&#"pageID"&"?]"])
with
baseUrl = http://server:6405/biprws
token = the result of the logon query (see my first post)
LatestInstanceID= ID of the document
pageID=ID of the report
And before that query is made I have another query browsing the document repository to find the latest instance of the report (scheduled to run every our on BO).
- sbo941209 years agoFrequent Visitor
yep just share the global query it's a interesting feature to explore
regards
- sbo941209 years agoFrequent Visitor
yep could you please post the detailed query you made to fix these 2 issues, including a explanation of the goal and structure of your query sent to a BO universe datasource.
regards
- Gautier9 years agoFrequent Visitor
Hi,
My query is structured as follow (with critical variables in red) :
1) authentication phase:
body = Text.ToBinary("<attrs>
<attr name=""userName"" type=""string""><username></attr>
<attr name=""password"" type=""string""><password></attr>
<attr name=""auth"" type=""string"" possibilities=""secEnterprise,secLDAP,secWinAD,secSAPR3"">secWinAD</attr>
</attrs>"),
baseUrl= http://server:6405/biprws,
options = [
Headers =[#"Content-type"="application/xml",#"Accept"="application/json"],
Content=body
],
result = Web.Contents(baseUrl, options),
#"Imported JSON" = Json.Document(result,1252),
token = #"Imported JSON"[logonToken]Now that we have retrieved a token we can get access SAP BO and retrieve the content of a Webi report
2) export report content as csv:
LatestInstanceID= ID of the document
pageID=ID of the report
Export latest instance as CSV = Web.Contents(baseUrl,[ Headers =[#"Content-type"="application/xml",#"X-SAP-LogonToken"=token,#"Accept"="text/csv"], RelativePath="raylight/v1/documents/"&#"Latest Instance ID"&"/reports/"&#"pageID"&"?]"])
The 2 issues I mentioned are solved as follow:
- unable to refresh on Power BI service when the logon token is retrieved through a function => simply integrate the authentication part of the query at the beginning of the query used to get the content of the report (no use of a separate function)
- Power BI services not accepting anonymous connection to web data source => used RevalivePath trick. Basically when Power BI services stores credentials for data sources it makes a test connection to the url provided in the query with the credentials given by the user. When Power BI service tries to access http://server:6405/biprws/raylight/v1/documents/etc. as anonymous the server will return an error => Power BI service will interpret this as incorrect credentials.
But if you use the RelativePath trick Power BI service will only test the baseurl http://server:6405/biprws and fortunately the server will return a different response to that url which will be accepted by Power BI service.
Hope this answers your questions !