Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
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!
Solved! Go to Solution.
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.
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.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
4 | |
3 | |
2 | |
2 | |
2 |