Power BI API POST 数据源错误 DMTS_InvalidEncryptionAlgorithmError
Power BI API POST datasource errors with DMTS_InvalidEncryptionAlgorithmError
我正在尝试使用 Microsoft Power BI API 在网关上创建新数据源 https://docs.microsoft.com/en-us/rest/api/power-bi/gateways/createdatasource。为了测试,我正在尝试使用基本身份验证创建到 Azure Sql 数据库 的连接。我可以使用 Power BI 在线 GUI 添加数据源而没有问题,但是每当我尝试使用 API 时,我都会收到 400 - DMTS_InvalidEncryptionAlgorithmError.
关键字段是body中的encryptionAlgorithm,但如API文档中所述,云应该是"None"数据源。
我也尝试过使用 "RSA-OAEP",但这给了我 400 - DM_GWPipeline_UnknownError。
我目前正在使用 Postman,但我也尝试使用 NodeJS 复制相同的请求并得到相同的结果。
任何关于解决方案的提示都会非常有帮助。
POST https://api.powerbi.com/v1.0/myorg/gateways/00000000-0000-0000-0000-000000000000/datasources
Headers
content-type: application/json,
Autorization: Bearer token
Body
{
"datasourceType": "Sql",
"connectionDetails": "{\"server\":\"servername.database.windows.net\",\"database\":\"dbname\"}",
"credentialDetails": {
"credentialType": "Basic",
"credentials": "{\"credentialData\":[{\"name\":\"username\", \"value\":\"myusername\"},{\"name\":\"password\", \"value\":\"mypwd\"}]}",
"encryptedConnection": "Encrypted",
"encryptionAlgorithm": "None",
"privacyLevel": "None"
},
"datasourceName": "new-datasource-name"
}
使用 "None" 时的错误消息 - HTTP 400
{
"error": {
"code": "DMTS_InvalidEncryptionAlgorithmError",
"pbi.error": {
"code": "DMTS_InvalidEncryptionAlgorithmError",
"parameters": {},
"details": [],
"exceptionCulprit": 1
}
}
}
使用 "RSA-OAEP" 时的错误消息 - HTTP 400
{
"error": {
"code": "DM_GWPipeline_UnknownError",
"pbi.error": {
"code": "DM_GWPipeline_UnknownError",
"parameters": {},
"details": [
{
"code": "DM_ErrorDetailNameCode_UnderlyingErrorMessage",
"detail": {
"type": 1,
"value": "The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. "
}
},
{
"code": "DM_ErrorDetailNameCode_UnderlyingHResult",
"detail": {
"type": 1,
"value": "-2146233033"
}
}
]
}
}
}
我认为您需要在加载时加密您的凭据 - 文档中没有说得很清楚。您不能只上传免费文本。
对安全有意义!
https://docs.microsoft.com/en-us/power-bi/developer/encrypt-credentials
为了完整起见,这里是您可以用来加密凭据的节点代码。使用库 node-rsa
const nodeRSA = require("node-rsa");
const credentials = '{\"credentialData\":[{\"name\":\"username\", \"value\":\"myusername\"},{\"name\":\"password\", \"value\":\"mypwd\"}]}';
const exponentString = 'AQAB';
const modulusString = 'rasdfsafsdfsadfsdafsdferasdasgfasgsfgdfgsdfgdsfgrgsrareasgasgasfasfasdfasdfsadfsadfgsadfsadfasfasdfsadfsdafasdfrgrhe4t345tge5g54g5gegdrg5tg45efgdfg5t=';
const key = new nodeRSA();
const modulus = new Buffer(modulusString, 'base64');
const exponent = new Buffer(exponentString, 'base64');
const pubKey = key.importKey({ n: modulus, e: exponent }, 'components-public');
const encrypted = pubKey.encrypt(credentials, 'base64');
console.log(encrypted)
我正在尝试使用 Microsoft Power BI API 在网关上创建新数据源 https://docs.microsoft.com/en-us/rest/api/power-bi/gateways/createdatasource。为了测试,我正在尝试使用基本身份验证创建到 Azure Sql 数据库 的连接。我可以使用 Power BI 在线 GUI 添加数据源而没有问题,但是每当我尝试使用 API 时,我都会收到 400 - DMTS_InvalidEncryptionAlgorithmError.
关键字段是body中的encryptionAlgorithm,但如API文档中所述,云应该是"None"数据源。
我也尝试过使用 "RSA-OAEP",但这给了我 400 - DM_GWPipeline_UnknownError。
我目前正在使用 Postman,但我也尝试使用 NodeJS 复制相同的请求并得到相同的结果。
任何关于解决方案的提示都会非常有帮助。
POST https://api.powerbi.com/v1.0/myorg/gateways/00000000-0000-0000-0000-000000000000/datasources
Headers
content-type: application/json,
Autorization: Bearer token
Body
{
"datasourceType": "Sql",
"connectionDetails": "{\"server\":\"servername.database.windows.net\",\"database\":\"dbname\"}",
"credentialDetails": {
"credentialType": "Basic",
"credentials": "{\"credentialData\":[{\"name\":\"username\", \"value\":\"myusername\"},{\"name\":\"password\", \"value\":\"mypwd\"}]}",
"encryptedConnection": "Encrypted",
"encryptionAlgorithm": "None",
"privacyLevel": "None"
},
"datasourceName": "new-datasource-name"
}
使用 "None" 时的错误消息 - HTTP 400
{
"error": {
"code": "DMTS_InvalidEncryptionAlgorithmError",
"pbi.error": {
"code": "DMTS_InvalidEncryptionAlgorithmError",
"parameters": {},
"details": [],
"exceptionCulprit": 1
}
}
}
使用 "RSA-OAEP" 时的错误消息 - HTTP 400
{
"error": {
"code": "DM_GWPipeline_UnknownError",
"pbi.error": {
"code": "DM_GWPipeline_UnknownError",
"parameters": {},
"details": [
{
"code": "DM_ErrorDetailNameCode_UnderlyingErrorMessage",
"detail": {
"type": 1,
"value": "The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. "
}
},
{
"code": "DM_ErrorDetailNameCode_UnderlyingHResult",
"detail": {
"type": 1,
"value": "-2146233033"
}
}
]
}
}
}
我认为您需要在加载时加密您的凭据 - 文档中没有说得很清楚。您不能只上传免费文本。
对安全有意义!
https://docs.microsoft.com/en-us/power-bi/developer/encrypt-credentials
为了完整起见,这里是您可以用来加密凭据的节点代码。使用库 node-rsa
const nodeRSA = require("node-rsa");
const credentials = '{\"credentialData\":[{\"name\":\"username\", \"value\":\"myusername\"},{\"name\":\"password\", \"value\":\"mypwd\"}]}';
const exponentString = 'AQAB';
const modulusString = 'rasdfsafsdfsadfsdafsdferasdasgfasgsfgdfgsdfgdsfgrgsrareasgasgasfasfasdfasdfsadfsadfgsadfsadfasfasdfsadfsdafasdfrgrhe4t345tge5g54g5gegdrg5tg45efgdfg5t=';
const key = new nodeRSA();
const modulus = new Buffer(modulusString, 'base64');
const exponent = new Buffer(exponentString, 'base64');
const pubKey = key.importKey({ n: modulus, e: exponent }, 'components-public');
const encrypted = pubKey.encrypt(credentials, 'base64');
console.log(encrypted)