Forum Discussion
InvalidRequest Error when updating dataset parameter only on a particular report
Hi,
I'm having trouble with updating dataset parameter on my report.
the process itself is quite simple :
1. request an oauth token
2. publish my template to power bi service
3. get the published dataset and report ID
4. update parameter on the published report's dataset
this is the code that I'm using :
function getDataset_Report(accessToken) {
xmlHttp.open("GET",getReportIDUrl,true);
xmlHttp.setRequestHeader('Authorization', 'Bearer '+accessToken);
xmlHttp.responseType = "json";
xmlHttp.onload = function () {
if (xmlHttp.readyState === xmlHttp.DONE) {
if (xmlHttp.status === 200) {
var d = xmlHttp.response.datasets;
var r = xmlHttp.response.reports;
if (r != 0 && d != 0) {
console.log('---------------start updating parameter----------------')
reportId = r[0].id;
console.log(reportId);
datasetId = d[0].id;
console.log(datasetId);
embUrl = r[0].embedUrl;
clearInterval(set_interval_id);
var changeParamUrl = "https://api.powerbi.com/v1.0/myorg/groups/" + groupId + "/datasets/" + datasetId + "/Default.UpdateParameters";
changeParam(changeParamUrl, accessToken, paramData, datasetId)
console.log('---------------finished updating parameter----------------')
} else {
run_getDataset_Report(accessToken)
}
}
else{
removeLoading();
};
}
}
xmlHttp.send();
}
function changeParam(theUrl,accessToken,paramData, datasetId) {
console.log(paramData);
xmlHttp.open("POST",theUrl,true);
xmlHttp.setRequestHeader('Authorization', 'Bearer '+accessToken);
xmlHttp.setRequestHeader("Content-type","application/json");
xmlHttp.onload = function () {
if (xmlHttp.readyState === xmlHttp.DONE) {
if (xmlHttp.status === 200) {
console.log('---------------start refreshing datasets----------------')
var getDatasourceUri = "https://api.powerbi.com/v1.0/myorg/groups/"+ groupId +"/datasets/" + datasetId + "/datasources"
getDatasourceInfo(getDatasourceUri, accessToken, paramData, datasetId)
console.log('---------------finished refreshing datasets----------------')
}
else{
removeLoading();
};
}
}
xmlHttp.send(paramData);
};
now the strange thing about this problem is I have 3 reports, 2 already existed reports and 1 new report.
this problem only occurred on my new report which I'm trying to publish.
when I use this code to update the parameter on the other two it works just fine.
now, I also compared the settings between my new report and the old one:
1. both already have the parameter "Enabled Load" checked
2. both are being released by the same application user, which have admin permission
3. both are being released to the same powerBI workspace
the only difference that I could think of is my new report is created after I updated my powerBI desktop,
but I don't think it would have any effects or whatsoever on this problem.
any insight would be greatly appreciated.
bests,