url = null;
try {
console.log("* postImport *");
if (isPaginatedReport) {
url = https://api.powerbi.com/v1.0/myorg/groups/${groupId}/imports?datasetDisplayName=${datasetDisplayName}&nameConflict=Abort
} else {
url = https://api.powerbi.com/v1.0/myorg/groups/${groupId}/imports?datasetDisplayName=${datasetDisplayName}&nameConflict=CreateOrOverwrite
}
const headers = await this.#powerBIAuth.getRequestHeader();
const form_data = new FormData();
form_data.append("value", stream);
function getLength() {
return new Promise((res, rej) => {
form_data.getLength((err, length) => {
if (err) {
return rej(err);
}
res(length);
})
})
}
const contentLength = await getLength();
const request_config = {
method: "post",
url: url,
headers: {
Authorization: headers.Authorization,
'Content-type': "multipart/form-data",
"Content-Length": contentLength
},
data: form_data
};
const response = await axios.request(request_config);
console.log('======================= postImport function completed');
return response
} catch (error) {
console.log("* post import error *");
if (error.response.data.error.code === "ReportWithDisplayNameForTheModelExists") {
this.url = https://api.powerbi.com/v1.0/myorg/groups/${groupId}/imports?datasetDisplayName=${datasetDisplayName}&nameConflict=Overwrite
const response = await this.postImport(stream, groupId, datasetDisplayName, isPaginatedReport)
return response
}
console.log(JSON.stringify(error));
if (error.response) {
throw new ErrorHandler(JSON.stringify(error.response.data.error), error.response.status);
} else {
throw error
}
}
}
In this function I'm trying to change the url variable value and calling the same function again in the catch block but url variable value is not changing .
is this js code ,right? so why there is no function after async?
Actually I'm writing it into the class .
{ "lenderName": "any", "sourceWorkSpaceId": "234234jdsfsd", "sourceReportId": "sdakfjsdk3423", "destinationWorkSpaceId": "jsdfsdjf324234", "datasetDisplayName": "test123_rdl", "displayReportName": "test123_rdl", "isPaginatedReport": true, "isLambdaInvocation": true } This is my payload for this function
Обсуждают сегодня