Comments on: How to use Power BI Embedded via REST/2016/07/20/power-bi-embedded-rest/Professional Development, Data ScienceMon, 06 Jan 2020 00:33:24 +0000hourly1http://wordpress.com/By: James Zicrov/2016/07/20/power-bi-embedded-rest/comment-page-1/#comment-4853Mon, 24 Sep 2018 06:55:56 +0000http://blogs.msdn.microsoft.com/tsmatsuz/?p=5345#comment-4853Hello everyone I have briefly read the entire blog and have to admit that it lays emphasis on each and every aspect of Power BI which actually is a very crucial business analytic service gifted by Microsoft.I don’t intend to question the blogger’s knowledge but just want to share some amount of information from my side as even I like to study about Power BI and so here is the link:

https://zappysys.com/blog/howto-import-json-rest-api-power-bi/

Like

]]>
By: SSS/2016/07/20/power-bi-embedded-rest/comment-page-1/#comment-1913Tue, 06 Mar 2018 06:05:12 +0000http://blogs.msdn.microsoft.com/tsmatsuz/?p=5345#comment-1913How to set refresh schedule after importing into workspace collection?

Like

]]>
By: Dushyant Singh Chouhan/2016/07/20/power-bi-embedded-rest/comment-page-1/#comment-340Thu, 15 Dec 2016 09:47:34 +0000http://blogs.msdn.microsoft.com/tsmatsuz/?p=5345#comment-340Can anyone convert the code in Javascript and comment or mail me at dushyantchouhan63@gmail.com

Like

]]>
By: Tsuyoshi Matsuzaki/2016/07/20/power-bi-embedded-rest/comment-page-1/#comment-339Tue, 01 Nov 2016 06:37:42 +0000http://blogs.msdn.microsoft.com/tsmatsuz/?p=5345#comment-339In reply to Thanos.

I’m sorry I’m not trying, but you can set the default schema for each user (such as, ALTER USER [user A] WITH DEFAULT_SCHEMA [user A’s schema]), and how about you can separate the default schema by setting the different credentials (user/password) for each PBI Embedded workspace ?

Like

]]>
By: Thanos/2016/07/20/power-bi-embedded-rest/comment-page-1/#comment-338Tue, 25 Oct 2016 11:22:05 +0000http://blogs.msdn.microsoft.com/tsmatsuz/?p=5345#comment-338I’m wondering how (and if) you can use the PowerBI Embedded with DirectQuery when the database is schema partitioned (for multi-tenancy and data isolation (legal reasons)). To make it more specific let me give you an example:
– In the Reporting Database, I have two schemas: CustomerA and CustomerB. So, the tables are like: CustomerA.Sales, CustomerB.Sales.

– Can I create a generic pbix report (with DirectQuery option), for example SalesReport, and then update somehow the connection string, so each Tenant could see his own data? Or I have to create one report per schema even though the data model is the same?
Have you ever tried it or see it in action?

Like

]]>
By: Tsuyoshi Matsuzaki/2016/07/20/power-bi-embedded-rest/comment-page-1/#comment-337Thu, 08 Sep 2016 01:11:51 +0000http://blogs.msdn.microsoft.com/tsmatsuz/?p=5345#comment-337In reply to Karim MB.

I’m sorry, I don’t have the client-side complete js example, and please refer https://blogs.msdn.microsoft.com/tsmatsuz/2016/07/06/how-to-get-azure-storage-rest-api-authorization-header/ for node.js example (i.e, server side js).
But, this error seems to be caused by the protocol unmatch. For example, if you’re using “https” in your site, you cannot call the api hosted by “http” because of the security reasons. This error (your reporting error) is saying your hosted js is having the protocol “file” (i.e, “file://…”) and cannot call the api hosted by “https”.
One additiional caveat is that the access token (which is retrieved from azure ibiza portal) should not be exposed in the client-side, because if the malicious code has retrieved your app token, they can do anything using this access token. (I’m not meaning the app token created by HMAC.) Then my sample is always including the server-side code.

Like

]]>
By: Karim MB/2016/07/20/power-bi-embedded-rest/comment-page-1/#comment-336Wed, 07 Sep 2016 10:14:08 +0000http://blogs.msdn.microsoft.com/tsmatsuz/?p=5345#comment-336Hi, Thanks for this tutorial it helps me a lot.
And I want to know if there a version with full Javascript. I search over the internet I didn’t find one.
I tried to convert the part of your code in javascript, but I didn’t work.

A Snip of the code:

Test page

<!– –>

function base64_encode( data ) {

var b64 = “ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=”;
var o1, o2, o3, h1, h2, h3, h4, bits, i = ac = 0, enc=””, tmp_arr = [];
data = utf8_encode(data);

do { // pack three octets into four hexets
o1 = data.charCodeAt(i++);
o2 = data.charCodeAt(i++);
o3 = data.charCodeAt(i++);

bits = o1<<16 | o2<>18 & 0x3f;
h2 = bits>>12 & 0x3f;
h3 = bits>>6 & 0x3f;
h4 = bits & 0x3f;

// use hexets to index into b64, and append result to encoded string
tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
} while (i < data.length);

enc = tmp_arr.join('');

switch( data.length % 3 ){
case 1:
enc = enc.slice(0, -2) + '==';
break;
case 2:
enc = enc.slice(0, -1) + '=';
break;
}

return enc;
}

function utf8_encode ( string ) {

string = (string+'').replace(/rn/g,"n");
var utftext = "";
var start, end;
var stringl = 0;

start = end = 0;
stringl = string.length;
for (var n = 0; n < stringl; n++) {
var c1 = string.charCodeAt(n);
var enc = null;

if (c1 127) && (c1 > 6) | 192) + String.fromCharCode((c1 & 63) | 128);
} else {
enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128);
}
if (enc != null) {
if (end > start) {
utftext += string.substring(start, end);
}
utftext += enc;
start = end = n+1;
}
}

if (end > start) {
utftext += string.substring(start, string.length);
}

return utftext;
}

var seconds = new Date() / 1000;
var heure = seconds+3600;
var accesskey= “7…==”;
var token1=”{” +
“”typ”:”JWT”,” +
“”alg”:”HS256″” +
“}”;
var token2 = “{” +
“”wid”:”a…73″,” + // workspace id
“”rid”:”e…d”,” + // report id
“”wcn”:”M…”,” + // workspace collection name
“”iss”:”PowerBISDK”,” +
“”ver”:”0.2.0″,” +
“”aud”:”https://analysis.windows.net/powerbi/api”,” +
“”nbf”:” + seconds + “,” +
“”exp”:” + heure +
“}”;
var inputval = rfc4648_base64_encode(token1) +”.” + rfc4648_base64_encode(token2);

var shaObj = new jsSHA(“SHA-256”, “TEXT”);
shaObj.setHMACKey(inputval, “TEXT”);
shaObj.update(accesskey);
var hash = shaObj.getHMAC(“HEX”);

//var hash = CryptoJS.HmacSHA256(inputval, accesskey);
var sig = rfc4648_base64_encode(hash);
var apptoken = inputval + “.” + sig;

function rfc4648_base64_encode(arg){
res = arg;
res = base64_encode(res);
res = res.replace(“/”, “_”);
res = res.replace(“+”, “-“);
res = res.replace(/=+$/, ”);
return res;
}
window.alert(apptoken);

View Report !

(function () {
document.getElementById(‘btnView’).onclick = function() {
var iframe = document.getElementById(‘ifrTile’);
iframe.src = ‘https://embedded.powerbi.com/appTokenReportEmbed?reportId=e…’;
iframe.onload = function() {
var msgJson = {
action: “loadReport”,
accessToken: apptoken,
height: 500,
width: 722
};
var msgTxt = JSON.stringify(msgJson);
iframe.contentWindow.postMessage(msgTxt, “*”);
};
};
}());

The errors :
– powerbiportal.common.bundle.min.js:40Uncaught SecurityError: Blocked a frame with origin “https://embedded.powerbi.com” from accessing a frame with origin “null”. The frame requesting access has a protocol of “https”, the frame being accessed has a protocol of “file”. Protocols must match.
– powerbiportal.explore.bundle.min.js:12Uncaught TypeError: Cannot read property ‘ResourcePackageReferenceResolver’ of undefined
– powerbireportembed.common.bundle.min.js:10Uncaught TypeError: Cannot read property ‘createController’ of undefined
– powerbiportal.dependencies.bundle.min.js:20 Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.5.3/$injector/modulerr?p0=powerbi.explore.rep…0.1605.432%2Fscripts%2Fpowerbiportal.dependencies.bundle.min.js%3A34%3A463)

Can you help me, please?

P.S: Sorry, for my english.

Like

]]>
By: Tsuyoshi Matsuzaki/2016/07/20/power-bi-embedded-rest/comment-page-1/#comment-335Wed, 20 Jul 2016 06:40:52 +0000http://blogs.msdn.microsoft.com/tsmatsuz/?p=5345#comment-335In reply to Simon.

Sorry again, but the report id is also included in the “iframe.src” in html. (This value must be also changed. Sorry.)

Like

]]>
By: Tsuyoshi Matsuzaki/2016/07/20/power-bi-embedded-rest/comment-page-1/#comment-334Wed, 20 Jul 2016 06:38:02 +0000http://blogs.msdn.microsoft.com/tsmatsuz/?p=5345#comment-334In reply to Simon.

Almost the reason of the error “This content is not available” is the invalid app token. (You can check the used app token value with Fiddler.)
If you copied my last PHP source code, please check if the values of $accesskey, wid (workspace id), rid (report id), and wcn (workspace collection name) are your own. Please change these 4 values for your own.
(You can also check these values using .NET console sample.)

Like

]]>
By: Simon/2016/07/20/power-bi-embedded-rest/comment-page-1/#comment-333Wed, 20 Jul 2016 06:07:45 +0000http://blogs.msdn.microsoft.com/tsmatsuz/?p=5345#comment-333I’ve taken your final example script plugged in my details and the page is loading simply with the message “This content is not available”

I’ve also encountered this error with PHP/javascript code of my own I’d written.

I’ve taken the same settings and used the provided .net example site from the getting started resources. That loads my report without issue.

Is there any known issues with the API at present? or am I missing a configuration change that is preventing my report from loading from a PHP/javascript based site?

I’m running these sites from Visual Studio and viewing in a firefox, IE and edge. My workspace is hosted in AustraliaSouthEast region.

Like

]]>