Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
TypeError: Cannot read property 'importState' of undefined at C:\Users\Admin\AppData\Roaming\npm\node_modules\powerbi-cli\lib\cli-impor t.js:69:70 at C:\Users\Admin\AppData\Roaming\npm\node_modules\powerbi-cli\node_modules\ powerbi-api\lib\autorest\operations\imports.js:416:14 at retryCallback (C:\Users\Admin\AppData\Roaming\npm\node_modules\powerbi-cl i\node_modules\ms-rest\lib\filters\systemErrorRetryPolicyFilter.js:85:9) at retryCallback (C:\Users\Admin\AppData\Roaming\npm\node_modules\powerbi-cl i\node_modules\ms-rest\lib\filters\exponentialRetryPolicyFilter.js:135:9) at handleRedirect (C:\Users\Admin\AppData\Roaming\npm\node_modules\powerbi-c li\node_modules\ms-rest\lib\filters\redirectFilter.js:36:9) at Request._callback (C:\Users\Admin\AppData\Roaming\npm\node_modules\powerb i-cli\node_modules\ms-rest\lib\requestPipeline.js:126:16) at Request.self.callback (C:\Users\Admin\AppData\Roaming\npm\node_modules\po werbi-cli\node_modules\request\request.js:187:22) at emitTwo (events.js:106:13) at Request.emit (events.js:191:7) at Request.<anonymous> (C:\Users\Admin\AppData\Roaming\npm\node_modules\powe rbi-cli\node_modules\request\request.js:1044:10) How it can be resolved, Is there any fix for the following error?
Solved! Go to Solution.
If you're using the NodeJS Power BI SDK, it is no longer supported. Try to directly call the REST API instead.
I don't know NodeJS, you can reference how I call the Create Import REST API in C#.
static void Main(string[] args) { //Import sample string pbixPath = @"C:\test\2.pbix"; string datasetDisplayName = "mydataset"; string importResponse = Import(string.Format("{0}/groups/{1}/imports?datasetDisplayName={2}", datasetsBetaUri, groupId, datasetDisplayName), pbixPath,"Bearer Token here"); Console.WriteLine(importResponse); } public static string Import(string url, string fileName,string bearerToken) { string responseStatusCode = string.Empty; string boundary = "---------------------------" + DateTime.Now.Ticks.ToString("x"); byte[] boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n"); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.ContentType = "multipart/form-data; boundary=" + boundary; request.Method = "POST"; request.KeepAlive = true; request.Headers.Add("Authorization", String.Format("Bearer {0}", bearerToken)); using (Stream rs = request.GetRequestStream()) { rs.Write(boundarybytes, 0, boundarybytes.Length); string headerTemplate = "Content-Disposition: form-data; filename=\"{0}\"\r\nContent-Type: application / octet - stream\r\n\r\n"; string header = string.Format(headerTemplate, fileName); byte[] headerbytes = System.Text.Encoding.UTF8.GetBytes(header); rs.Write(headerbytes, 0, headerbytes.Length); using (FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { byte[] buffer = new byte[4096]; int bytesRead = 0; while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0) { rs.Write(buffer, 0, bytesRead); } } byte[] trailer = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n"); rs.Write(trailer, 0, trailer.Length); } using (HttpWebResponse response = request.GetResponse() as System.Net.HttpWebResponse) { responseStatusCode = response.StatusCode.ToString(); } return responseStatusCode; }
TypeError: Cannot read property 'importState' of undefined at C:\Users\Admin\AppData\Roaming\npm\node_modules\powerbi-cli\lib\cli-impor t.js:69:70 at C:\Users\Admin\AppData\Roaming\npm\node_modules\powerbi-cli\node_modules\ powerbi-api\lib\autorest\operations\imports.js:416:14 at retryCallback (C:\Users\Admin\AppData\Roaming\npm\node_modules\powerbi-cl i\node_modules\ms-rest\lib\filters\systemErrorRetryPolicyFilter.js:85:9) at retryCallback (C:\Users\Admin\AppData\Roaming\npm\node_modules\powerbi-cl i\node_modules\ms-rest\lib\filters\exponentialRetryPolicyFilter.js:135:9) at handleRedirect (C:\Users\Admin\AppData\Roaming\npm\node_modules\powerbi-c li\node_modules\ms-rest\lib\filters\redirectFilter.js:36:9) at Request._callback (C:\Users\Admin\AppData\Roaming\npm\node_modules\powerb i-cli\node_modules\ms-rest\lib\requestPipeline.js:126:16) at Request.self.callback (C:\Users\Admin\AppData\Roaming\npm\node_modules\po werbi-cli\node_modules\request\request.js:187:22) at emitTwo (events.js:106:13) at Request.emit (events.js:191:7) at Request.<anonymous> (C:\Users\Admin\AppData\Roaming\npm\node_modules\powe rbi-cli\node_modules\request\request.js:1044:10) How it can be resolved, Is there any fix for the following error?
If you're using the NodeJS Power BI SDK, it is no longer supported. Try to directly call the REST API instead.
I don't know NodeJS, you can reference how I call the Create Import REST API in C#.
static void Main(string[] args) { //Import sample string pbixPath = @"C:\test\2.pbix"; string datasetDisplayName = "mydataset"; string importResponse = Import(string.Format("{0}/groups/{1}/imports?datasetDisplayName={2}", datasetsBetaUri, groupId, datasetDisplayName), pbixPath,"Bearer Token here"); Console.WriteLine(importResponse); } public static string Import(string url, string fileName,string bearerToken) { string responseStatusCode = string.Empty; string boundary = "---------------------------" + DateTime.Now.Ticks.ToString("x"); byte[] boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n"); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.ContentType = "multipart/form-data; boundary=" + boundary; request.Method = "POST"; request.KeepAlive = true; request.Headers.Add("Authorization", String.Format("Bearer {0}", bearerToken)); using (Stream rs = request.GetRequestStream()) { rs.Write(boundarybytes, 0, boundarybytes.Length); string headerTemplate = "Content-Disposition: form-data; filename=\"{0}\"\r\nContent-Type: application / octet - stream\r\n\r\n"; string header = string.Format(headerTemplate, fileName); byte[] headerbytes = System.Text.Encoding.UTF8.GetBytes(header); rs.Write(headerbytes, 0, headerbytes.Length); using (FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { byte[] buffer = new byte[4096]; int bytesRead = 0; while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0) { rs.Write(buffer, 0, bytesRead); } } byte[] trailer = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n"); rs.Write(trailer, 0, trailer.Length); } using (HttpWebResponse response = request.GetResponse() as System.Net.HttpWebResponse) { responseStatusCode = response.StatusCode.ToString(); } return responseStatusCode; }
User | Count |
---|---|
8 | |
7 | |
2 | |
2 | |
2 |
User | Count |
---|---|
6 | |
5 | |
4 | |
4 | |
4 |