cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Zuv Frequent Visitor
Frequent Visitor

help need on updating dataset credentials on PowerBI Embedded

I am using PowerBI embedded with rest api calls, all the datasets sits under Azure Sql.

I have written easily rest api calls with php and cURL, like -- detele dataset, upload reports, get workspaces etc. All went smoothly.

 

I got stuck on DirectQuery Reports with updating credentials to it with REST API.

As I know first I need to run Get GetBoundGatewayDatasources operation in order to get Datasource ID and ID and then patch it with a call:

PATCH https://api.powerbi.com/v1.0/collections/mywsc01/workspaces/32960a09-6366-4208-a8bb-9e0678cdbb9d/gateways/ca17e77f-1b51-429b-b059-6b3e3e9685d1/datasources/5f7ee2e7-4851-44a1-8b75-3eb01309d0ea
Authorization: AppKey 9BKsnTVkRP...
Content-Type: application/json; charset=utf-8

{
  "credentialType": "Basic",
  "basicCredentials": {
    "username": "demouser",
    "password": "P@ssw0rd"
  }
}

All seems pretty easy, the problem is I can't get results from this  Get GetBoundGatewayDatasources call, it just says in header 404 not found.

There is an article about all the workflow and they mentions that:

"Note : If the error of 404 Not Found occurs, please change (re-create) the location of the Power BI Embedded resource in Azure Portal. (Please see the note above.)"

Well, I have used workspace under US and other one under WEST EU. Do you have any ideas?

The whole article I fallowed by: https://blogs.msdn.microsoft.com/tsmatsuz/2016/07/20/power-bi-embedded-rest/

 

It's pretty old one, maybe they do have other solutions to update those credentials for datasets (pbix files). Mine datasets sits under Azure SQL and uses DirectQuery.

Seems like they still have path method in documentation as well as GetBoundGatewayDatasources method..

This is my code:

  public function getGatewayDatasource($workspaceId, $datasetId) {

	   				$key = env('ACCESS_KEY');
					$collection_name = env('WORKSPACE_COLLECTION');
					
					$ch = curl_init();
					curl_setopt($ch, CURLOPT_HEADER, 1);
					curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

                    curl_setopt($ch, CURLOPT_URL, "https://api.powerbi.com/v1.0/collections/".$collection_name."/workspaces/".$workspaceId."/".$datasetId."/Default.GetBoundGatewayDatasources");


                    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                    // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //Might be required for https
                    curl_setopt($ch, CURLOPT_HTTPHEADER, [
                        "Authorization: AppKey " . $key
                    ]);
                    $response_json = curl_exec($ch);

                    $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

                    curl_close($ch);

                    if ($httpcode == 200) {
                    	$message = 'success';
                    }
                    else {
                    	$message = $response_json;
                    }
                    // $response_data = json_decode($response_json, true);

            return ($response_json);


	   }

If you have any ideas about it, would be great to know. 

Many thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator Eric_Zhang
Moderator

Re: help need on updating dataset credentials on PowerBI Embedded

@Zuv

Those GetBoundGatewayDatasources and GatewayDatasource both work in my test.

When reviewing your code, I've found the the API url is wrong, you're missing the highlighted part.

 

https://api.powerbi.com/v1.0/collections/{collectionName}/workspaces/{workspaceId}/datasets/{datasetKey}/Default.GetBoundGatewayDatasources

Please review your code and ensure that the collectionName, workspaceId and datasetId(some one put a report id here) are all correct.

 

1 REPLY 1
Moderator Eric_Zhang
Moderator

Re: help need on updating dataset credentials on PowerBI Embedded

@Zuv

Those GetBoundGatewayDatasources and GatewayDatasource both work in my test.

When reviewing your code, I've found the the API url is wrong, you're missing the highlighted part.

 

https://api.powerbi.com/v1.0/collections/{collectionName}/workspaces/{workspaceId}/datasets/{datasetKey}/Default.GetBoundGatewayDatasources

Please review your code and ensure that the collectionName, workspaceId and datasetId(some one put a report id here) are all correct.

 

Helpful resources

Announcements
Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Virtual Launch Event

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Top Kudoed Authors
Users Online
Currently online: 162 members 1,769 guests
Please welcome our newest community members: