Forum Discussion
Getting "Bad Request" for BindToGatewayInGroup() although nothing seems to be wrong
I'm working on an automation which should export an existing report, import it to a new workspace and bind it to a new Datasource.
The problem is that when executing the BindToGatewayInGroup, I get the below response although the new Datasource is clearly there and the status of the Datasource on the PowerBi app platform is "Online"
{
"error": {
"code": "DMTS_CanNotFindMatchingDatasourceInGatewayError",
"pbi.error": {
"code": "DMTS_CanNotFindMatchingDatasourceInGatewayError",
"parameters": {},
"details": [],
"exceptionCulprit": 1
}
}
}
Here is my code:
public void BindToGatewayInGroup(Group group, Dataset dataset, GatewayDatasource datasource)
{
try
{
var serviceURL = PBI_API_BASE + $"groups/{group.Id}/datasets/{dataset.Id}/Default.BindToGateway";
var datasourceObjectIdsArray = new[] { datasource.Id.ToString() };
var requestBody = JsonConvert.SerializeObject(new { gatewayObjectId = datasource.GatewayId.ToString(), datasourceObjectIds = datasourceObjectIdsArray });
var content = new StringContent(requestBody, Encoding.UTF8, "application/json");
var response = Client.PostAsync(serviceURL, content).Result;
if (!response.IsSuccessStatusCode)
{
throw new Exception($"Status = {response.StatusCode}");
}
else
{
return;
}
}
catch (Exception ex)
{
throw ex;
}
}
Here is my requestbody:
{"gatewayObjectId":"754e1e6e-9777-4f4d-bf1b-9eb0405ac085","datasourceObjectIds":["9003c27f-bc4f-4b0c-88f0-2294d542e068"]}
1 Reply
- AnonymousNot applicable
Hi Tom-ADV ,
I found some links which has the similar problem as yours, please check if their solution. Hope they can help you resolve the problem.
powerbi-powershell/bindtogateway.ps1 at master · Azure-Samples/powerbi-powershell · GitHub
Solved: Enterprise Gateway refresh error to on-premise SQL... - Microsoft Power BI Community
the Tech Staff told me that 400 error was about a PowerBIErrorCode: DMTS_CanNotFindMatchingDatasourceInGatewayError.
The enterprise gateway was not able to find all datasource, even if on the first check it was.
Solutions is to manually check all the datasource of the report and all the datasource on the enterprise gateway.
Re: gateway "not configured correctly" - Microsoft Power BI Community (Check message 10)
Solved: Re: Power Bi gateway "not configured correctly" - Microsoft Power BI Community
I have found out the issue. There were two data sources in my dataset. One onpremise sql server and other one is excel file stored in one drive.
In Gateway Cluster Settings I have not ticked "Allow user's cloud data sources to refresh thorufh this gatway cluster" option. After ticked it and saved it. I was able to setup the gatway connection.
Best Regards