Quantcast
Channel: Developer topics
Viewing all 17950 articles
Browse latest View live

Unable to generate Access Token with .NET Core

$
0
0

I'm trying to Embed Power BI Report using .NET Core Web Application and Angular. For this I used PowerBIEmbedded_AppOwnsData( .NET MVC) sample and successfully able to generate tokens and embed the report there

 

But in .NET Core Application as there is no AcquireTokenAsync method so I refered this Embed Power BI dashboard in ASP.Net core  which uses Resource Owner Password Credentials Grant flow and in the below coding using the same request body as I used earlier in PowerBIEmbedded_AppOwnsData(.NET) App.

 

 

 private async Task<OAuthResult> AuthenticateAsync()
        {
            var oauthEndpoint = new Uri("https://login.microsoftonline.com/common/oauth2/token");
            using (var client = new HttpClient())
            {
                var result = await client.PostAsync(oauthEndpoint, new FormUrlEncodedContent(new[]
                 {
                     new KeyValuePair<string,string>("resource", "https://analysis.windows.net/powerbi/api"),
                     new KeyValuePair<string,string>("client_id", ApplicationId),
                     new KeyValuePair<string,string>("client_secret", ApplicationSecret),
                     new KeyValuePair<string,string>("grant_type", "password"),
                     new KeyValuePair<string,string>("username", Username),
                     new KeyValuePair<string,string>("password", Password),
                     new KeyValuePair<string,string>("scope", "openid")
                 }
                ));

                var content = await result.Content.ReadAsStringAsync();
                return JsonConvert.DeserializeObject<OAuthResult>(content);
            }

        }

 

 

But this time I am getting an error response which was succesful in .NET Sample

 

{
    "error": "invalid_grant",
    "error_description": "AADSTS50126: Invalid username or password.\r\nTrace ID: e4813657-d71a-480c-87a2-1140a49b6f00\r\nCorrelation ID: ba79a622-32e2-4a12-b7fd-65a21a99f378\r\nTimestamp: 2019-05-07 09:46:05Z",
    "error_codes": [
        50126
    ],
    "timestamp": "2019-05-07 09:46:05Z",
    "trace_id": "e4813657-d71a-480c-87a2-1140a49b6f00",
    "correlation_id": "ba79a622-32e2-4a12-b7fd-65a21a99f378"
}

Please Help

 

 


Custom Visual - To implement Date Range Picker

$
0
0

Hi,

 

I am making a custom visual with dropdown values like Today, Yesterday and Custom Dates. If I click custom dates, it should open a date range picker. I also followed other thread mentioned here. https://community.powerbi.com/t5/Developer/Date-Range-Custom-visual/td-p/296757

I am using jquery and date range picker from http://daterangepicker.com 

To Note:- Current pbiviz version installed - 3.0.12

 

My package.json libraries entry look like this:

 

 
 "@types/daterangepicker": "^2.1.17",
    "@types/jquery": "^2.0.41",
    "bootstrap": "^4.3.1",
    "d3": "^5.9.2",
    "daterangepicker": "^3.0.5",
    "jquery": "^3.2.1",
 

Even jQuery is working fine in my visual.ts file. For example, this code works like magic:

import * as $ from "jquery";

private $root: JQuery;
private $searchHeader: JQuery;

update() {
this.$root = $("#sandbox-host").addClass("custom-jquery");
      this.$root.append('<form id="mySearch"></form>');
      this.$searchHeader = $('#mySearch').append('<input name="datefilter" type="text" 
      value="01/01/2018 - 01/15/2018" class="form-control" />');
}

But, at this line, it gives me the error.

$('input[name="datefilter"]').daterangepicker({
        opens: 'left'
      }, function(start, end, label) {
        console.log("A new date selection was made: " + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD'));
      });

Error in console is - jquery__WEBPACK_IMPORTED_MODULE_124__(...).daterangepicker is not a function

 

 I have seen you tried similarly to fix other issues. I would be glad if I get some help here.

Dynamic Row level Security with Azure Analysis Service

$
0
0

I'm using Azure Analysis service for a Power BI, i have one doubt in Dynamic row level security. Im using USERNAME() & LOOKUPVALUE function to provide security here.

 

Is it possible to provide access to all the users to all the AD Groups, if there is NULL present in <search_value> of the LOOKUPVALUE function?

 

suppose, there are 100 users who are part of 10 AD Groups, and access to these users are provided based on the AD Group Code. (AD Group 1, AD Group Code1 ................)

AD Groups codes are associated with some Products, if there no AD Groups Available for a Product, then that product should be visible to all the users. Is this Possible?

Create JSON file using Python Script and reading it from the script

$
0
0

I am developing an API integration to use it on Power BI. The problem is that I have done this integration in a Python Script.

Here is the code:

import requests
import json

app_key = "1560731700"#EXAMPLE APP KEY
app_secret = "226dcf372489bb45ceede61bfd98f0f1" #EXAMPLE APP SECRET

response = requests.get('https://app.omie.com.br/api/v1/financas/contapagar/?JSON={"call":"ListarContasPagar","app_key":"%s","app_secret":"%s","param":[{"pagina":1,"registros_por_pagina":100,"apenas_importado_api":"N"}]}'%(app_key,app_secret)).status_code
if response != 200:
    print("Invalid Parameters")
else:
    response = requests.get('https://app.omie.com.br/api/v1/financas/contapagar/?JSON={"call":"ListarContasPagar","app_key":"%s","app_secret":"%s","param":[{"pagina":1,"registros_por_pagina":100,"apenas_importado_api":"N"}]}'%(app_key,app_secret)).json()
    total = response["total_de_paginas"]
    contas_pagar = response["conta_pagar_cadastro"]
    for i in range(1, total + 1):
        response = requests.get('https://app.omie.com.br/api/v1/financas/contapagar/?JSON={"call":"ListarContasPagar","app_key":"%s","app_secret":"%s","param":[{"pagina":%s,"registros_por_pagina":100,"apenas_importado_api":"N"}]}'%(app_key,app_secret,i)).json()
        
        with open("teste.json", "w") as teste: #I created a file called teste.json to dump the initial json.
            json.dump(contas_pagar,teste,indent=4)
            
        
        with open("teste.json", "r") as teste: #then I recall it, with readlines
            lines = teste.readlines()
        
        if i == 1:
            mode = "w"
        else:
            mode = "a"
            
        if i != total:
            with open("resultado.json", mode) as teste: #and write it down on another one!
                for b in range(len(lines)-1):
                    if b == 0 and mode == "a":
                        pass
                    elif b == len(lines) - 2:
                        teste.write(str(lines[b]).rstrip("\n") + ",")
                    else:
                        teste.write(lines[b])
                
        if i == total:
            with open("resultado.json", mode) as teste:
                for b in range(len(lines)-1):
                    if b == 0 and mode == "a":
                        pass
                    else:
                        teste.write(lines[b])
                teste.write("]")

        print("Page completed: %s" %i)

The problem is that my code generates 2 new json files while executing and I can't use dataset=teste on the code, because Power BI doesn't recognize it. 

Is there anyway I can read the resultado.json file on Power BI generated on Python Script?

PS: I have to run this code on PBI, to keep the flow automatically

Power BI oAuth 403 - Forbidden

$
0
0

Hi, i wan`t to integrate my own platform showing Power BI dashboards. For that, first i created an app on my Azure account, giving the permissions to: 

- Azure Active Directory Graph: Users.Read, Users.Read.All (Type: Delegated)

- Power BI Service: Full access. (Type: Delegated)

Then, I authenticated using grant type authorization_code flow oAuth protocol. As a result, I obtained an Access Token.

So, the following step, should be making a request to Power BI Api for getting the dashboard, like this:

HTTP GET https://api.powerbi.com/v1.0/{tenantId}/dashboards/{dashboardId}

Header: Authorization Bearer <token>

But i get a 403 response code, forbidden. 

Also, I checked the scopes which the Access Token has, and it seems to has only the Azure Active Directory Graph permissions. I don`t understand why it doesn`t have the Power Bi Service scopes too.

 

Thanks

 

Seeking solutions for RLS on an embedded report using a live connection

$
0
0

I'd like to pick the community's brain on solutions for RLS when a report is embedded. 

 

Currently, we use RLS on Power BI using an import connection to an analysis services cube. Our web app passes the identifier to the report & users only see what they should. The issue is that import is a difficult model to maintain when you're working with a lot of data. I'd like to move toward a live conneciton, though I know it is not supported. 

 

Would it be possible to setup RLS on the Analysis Services side, create a report using a live connection, publish & embed this to use RLS?

 

Would it be possible to use parameters in any way to mimic RLS using a live connection?

 

Thank you in advance!

Power BI developer license

$
0
0

Hi Community,

I have just received a request for a power bi developper license, is there any such license and how much does it cost ? As I know there is only two power bi licenses beside the free version. the Pro license (9,99 $/user/month) and the premium license whose cost is basd on the cores number.

 

Thank you in advance for your clarifications.

 

 

Embedded RLS - Apps owns data - Dynamic usernames

$
0
0

Hi there,

 

Read several posts/blogs but still got a question. We have a portal which embedded power bi (non power bi users / apps owns data). 

 

1. At the generatetokenrequest, we can lookup the 'EffectiveIdentity'. Is it possible to lookup a SQL table? Based on the e-mail login for the portal? So if a client logs into the portal with its e-mail/username it will lookup this e-mail/username in the SQL table and pass the customer code (from the SQL table) as username for power BI?

 

2. Is it possible to pass multiple usernames? So client A, is linked to customer code 112 & 113. Pass this as usernames to power bi.  In the power bi report RLS filters the customer code tabel on 112 & 113. Or do I need to make a table inside PowerBI which links username 112, to multiple other codes (113/114 etc)?

 

Thank you in advance!


Avoid Replicating Data Sources in Data Gateway with Changing Parameters

$
0
0

Hoping someone can give some advice on this, I haven't seen the issue in all my searching online thus far.

 

I've written a custom connector which uses OAuth2 to hit an API with a query to retreive data I need. I've added a drop down for PowerBI Desktop so the user can select a query option as their parameter. This all works great in Desktop. I have added the custom connector to a Data Gateway so I can schedule data refreshes for the reports I am building. Here is where my issue lies:

 

I have to create a new data source under the data gateway for every possible paremeter option for the API call. This creates a ridiculous amount of overhead for either our end users or myself to populate all these data sources, even though the authentication is exactly the same. This is not sustainable.

 

Does anyone know of a way to enable data refresh for my custom connectors without having to explicitly write out every possible parameter option in the data gateway?

 

Thanks!

Prompt Optional Parameters of Queries

$
0
0

I have created a custom connector with several queries in it and I have imported this into Power BI Desktop.

 

here is a simple example of my code:

shared MyQuery.Contents = (optional input as text) =>

     let

          content = Web.Contents("http://my-api-url.com/endpoint"), [HeaderStuff],

          data = Json.Document(content)[data]

     in

          data;

 

I know the query itself works. My problem is this optional input is not prompted for the user! If I remove the optional keyword then it will prompt for input or if I add an additional required parameter it will prompt for the optional input as well. Is there a solution for this? I only have an optional parameter but I need to give the option of filling it in.

 

I think I can add the input value directly to the query string: MyQuery.Contents("optionalInput") but that's not ideal for my end users compared to a prompt. Also, I am using a dropdown menu so I don't want users to have to type the value itself.

 

Anyone figured out how to create a query with all optional params?

Power BI Embedded in PowerApps

$
0
0

Hi

 

I'm wondering if it is possible to embed a full power BI report in a PowerApps Application so users can interact with the report from inside the PowerApps application.

 

If yes, is this supported with Power BI Premium?

 

Greets

Power BI REST API GetReportsInGroupAsAdmin returning deleted items, anyway around this?

$
0
0

Hi folks,

 

I'm using the GetReportsInGroupAsAdmin and GetDatasetsInGroupAsAdmin methods in the REST API to create an inventory of items in our tenant.  We are not on Premium.

 

I've found that these methods return items that do NOT appear in the service UI.  I assume they were there and are deleted.  The Dataset and Report objects that are returned do not have any State property that indicates these items are not valid.  I'm wondering if anyone has seen this and/or has a solution.  There is a filter parm for the calls but I'm unsure of what property could be used as one does not get returned in the response that would indicate the deletion.

 

I could call the GetDatasetByID method passing in the group and dataset id and that method does create a NotFound exception but I'd rather not go that route.  I also noticed that the regular GetDatasetsInGroup method does NOT return the deleted items.

 

I am using the wrapper assembly provided on Nuget.

 

Any ideas are appreciated,

Thanks

scatter plot with date on the x-axis, why so hard ?

$
0
0

I need present data at every minutes (data type: datetime), and sorted,  sort at top right corner. my datetime on x-axis not sorting... if not sort, why sort feature is there ? looks like someone suggest to use line chart... with few steps.. why so complicated, all other tool, very easy to do so..

Capture.PNG

 

"skipReport=True" in import gives error in RestAPI

$
0
0

Hi,

 

When I use skipReport=True in import rest API, my code doesn't work and gives 404 error message in response code.

This work fines:

 

 try {
            "== Importing $report_name to target workspace"
            $uri = "https://api.powerbi.com/v1.0/$target_group_path/imports/?datasetDisplayName=$report_name.pbix&nameConflict=Overwrite"

            # Here we switch to HttpClient class to help POST the form data for importing PBIX
            $httpClient = New-Object System.Net.Http.Httpclient $httpClientHandler
            $httpClient.DefaultRequestHeaders.Authorization = New-Object System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", $token.AccessToken);
            $packageFileStream = New-Object System.IO.FileStream @($temp_path, [System.IO.FileMode]:Smiley Surprisedpen)
            $contentDispositionHeaderValue = New-Object System.Net.Http.Headers.ContentDispositionHeaderValue "form-data"
            $contentDispositionHeaderValue.Name = "file0"
            $contentDispositionHeaderValue.FileName = $file_name
            $streamContent = New-Object System.Net.Http.StreamContent $packageFileStream
            $streamContent.Headers.ContentDisposition = $contentDispositionHeaderValue
            $content = New-Object System.Net.Http.MultipartFormDataContent
            $content.Add($streamContent)
            $response = $httpClient.PostAsync($Uri, $content).Result            
            Write-Verbose -Verbose $response
            if (!$response.IsSuccessStatusCode) {
                $responseBody = $response.Content.ReadAsStringAsync().Result
                "= This report cannot be imported to target workspace. Skipping..."
                $errorMessage = "Status code {0}. Reason {1}. Server reported the following message: {2}." -f $response.StatusCode, $response.ReasonPhrase, $responseBody
                throw [System.Net.Http.HttpRequestException] $errorMessage
            } 

This don't:

try {
            "== Importing $report_name to target workspace"
            $uri = "https://api.powerbi.com/v1.0/$target_group_path/imports/?datasetDisplayName=$report_name.pbix&nameConflict=Overwrite&skipReport=True"

            # Here we switch to HttpClient class to help POST the form data for importing PBIX
            $httpClient = New-Object System.Net.Http.Httpclient $httpClientHandler
            $httpClient.DefaultRequestHeaders.Authorization = New-Object System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", $token.AccessToken);
            $packageFileStream = New-Object System.IO.FileStream @($temp_path, [System.IO.FileMode]:Smiley Surprisedpen)
            $contentDispositionHeaderValue = New-Object System.Net.Http.Headers.ContentDispositionHeaderValue "form-data"
            $contentDispositionHeaderValue.Name = "file0"
            $contentDispositionHeaderValue.FileName = $file_name
            $streamContent = New-Object System.Net.Http.StreamContent $packageFileStream
            $streamContent.Headers.ContentDisposition = $contentDispositionHeaderValue
            $content = New-Object System.Net.Http.MultipartFormDataContent
            $content.Add($streamContent)
            $response = $httpClient.PostAsync($Uri, $content).Result            
            Write-Verbose -Verbose $response    
            if (!$response.IsSuccessStatusCode) {
                $responseBody = $response.Content.ReadAsStringAsync().Result
                "= This report cannot be imported to target workspace. Skipping..."
                $errorMessage = "Status code {0}. Reason {1}. Server reported the following message: {2}." -f $response.StatusCode, $response.ReasonPhrase, $responseBody
                throw [System.Net.Http.HttpRequestException] $errorMessage
            }

Only change is I have added &skipReport=True in uri.

 

Can you please help to solve this. Basically I just want to import dataset not report.

 

Thank you in advance!

 

Regards,

Niket Talati

 

Power BI Embedded Capacity & SharePoint Online

$
0
0

Hello,

 

I have a Power BI report in embedded capacity (A1), and I've added it as a webpart on our company's sharepoint online site. And our Power BI Free Account Users can access to the report in SharePoint.

 

 

When I checked the website (https://docs.microsoft.com/en-us/power-bi/developer/embedded-faq), it says that the Power BI Embedded Capacity can not consume Power BI Reports in SharePoint.

 

 

The current situation (Can embed a report to sharepoint and those who do not have pro-license can see the report in SharePoint) is OK, but I was wondering how come, based on the document link above...

 

I just would like to make it sure so that I can process other reports to be shared through the SharePoint site.

 

 

Thank you in advance for your help.


Need help on Rest API connection

$
0
0

Hi All, 

 

I'm trying to create a tool that connects to Baidu Maps API to extract travel time data based on the different modes of transport. 

 

I've successfully manage to create a custom function that allows dynamic changes to Start and End destinations. However, results i get from Baidu maps is that the "App is not present, there is error in the AK" refer to Column D . When i tested the URL link in a blank webpage, it manage to return valid results for the Start and End locations if i typed in manually. However, if i copy the data from the cell into the URL, it gives error (shown below). Appreciate if anyone can enlighten on what went wrong. Thanks.

 

(Start as text, End as text) => 

let 

   Baidu_API_key = "API_key", 
   Distance_lite = Web.Contents("http://api.map.baidu.com/directionlite/v1/driving?origin=Start&destination=End&ak=Baidu_API_key"),
   Results = Json.Document(Distance_lite)

in

Results

Error.PNG

 

 

error 2.PNG

 

Need Help with performing measure within "Measure"

$
0
0
I'm trying to calculate some criteria in a column using "if" condition(looping), but it's only checking the first "if" condition and giving the single value (IF([% of Assets added during the Quarter] &gt;= 5, 5,).&nbsp;
When I'm using the same formula in the measure column then it is working correctly.
After creating criteria I have to find out an average of it also.
--------------------------------------------------------------------------------------------------------------------
DAX Formulas&nbsp; for Criteria:&nbsp;Avila Score Crit = IF(ISBLANK([% of Assets added during the Quarter]), BLANK(),
IF([% of Assets added during the Quarter] &gt;= 5, 5,
IF(AND([% of Assets added during the Quarter] &lt; 3.5, [% of Assets added during the Quarter] &gt; 5),3,
IF([% of Assets added during the Quarter] &lt;=3.5,1))))&nbsp;
----------------------------------------------------------------------------------------------------------------------
Avila Score is "Measure" and after this is "Column".

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;

How to control OnHover JSON Theme values for action buttons

$
0
0

How do I go about controlling the values for the 'On Hover' seciont for Fill within a Action Button?

 

I have experimented with this (and close derivatives around this), however this doesn't seem to work.

Would be quite nice to know how to control the 'Default State', 'On Hover' and 'On Press' 

 

"actionButton":{"*":
	{
	"fill":
		[{
			"show":true,
			"onHover":
				{
				"fillColor":{"solid":{"color":"#25476E"}},
				"transparency":0
				}	
		}],

	}},

Sales analytics for Dynamics 365 app customization

$
0
0

Hi,

 

I've been looking into the "Sales analytics for Dynamics 365" app from appsource and have a hard time finding a way to customize it in any way. From what I found out that doesn't seem to be possible with apps compared to content packs where you could also see the underlying dataset and also save a copy or download a pbix file. As I understand none of this is possible with apps is that correct?

I was trying to do some basic filtering in report view and then have it reflected in the dashboard but not even that seems to work. Whenever I refresh the dashboard it's still showing the default filtering. Am I missing something here?

 

Appreciate some help!

 

BR

Henrik

To show Custom Visual out of containing iframe

$
0
0

Objective - My custom visual is a date range picker which is currently residing in an iframe generated by powerbit or pbiviz API. If my custom visual container height is less, date range picker which that is opening is hiding behind the walls of this iframe which is correct HTML behavior. I want this particular date range custom visual to show on top of all the containng area just like "Date Slicer" which opens datepicker freely.

 

How can I do that? I already have two threads related to same issue on GitHub and StackOverflow which are mentioned below respectively.

To show custom visual outside iframe container #544

To have reference to outer most <body> tag from the iFrame

 

If you see these threads, you get what I want to achieve here. Few points to mention:

 

  • Power BI Date Slicer which opens Datepicker doesn't add any iframe in HTML if you inspect and check it. Thus making it easier to use jQuery and attaching datepicker freely in DOM area. While Custom visual are automatically being added in an iframe.
  • Is there any way we can communicate outside area of this iframe. If I am using legacy methods to access parent outide area using, top.window then most of its properties like "document" does have this error if you try to access it. 

    Exception: DOMException: Blocked a frame with origin "null" from accessing a cross-origin frame. at invokeGetter (<anonymous>:2:14

  •  

    Ofcourse this is Cross origin issue because iframe is loaded as https://powerbi.com while working environment of powerbi is without HTTPS and other host, parameters issues.
  • To communicate and listening between both worlds of iframe and outer containing area, we need access to code which is holding this iframe custom visuals which is not possible I believe as we are merely trying to develop custom visuals for already created application.
  • Is there configuration available which allows to inject/append this custom visual without an iframe itself like normal divs (as done for date slicer)? 
Viewing all 17950 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>