问题描述
我正在尝试连接到在Power BI中使用HMAC-SHA256哈希(https://apidocs.unleashedsoftware.com/AuthenticationHelp)的API。我发现,要执行此操作,我需要在Visual Studio中下载数据连接器项目SDK,并在M内使用名为crypto.createhmac(https://nodejs.org/api/crypto.html)的node.js函数。但是,当我在数据连接器代码中使用此函数时,它要求的是第三个参数“ value as binary”,但这不在node.js文档中。下面是我最终将在Power BI中使用的数据连接器的代码。
section TripPin;
[DataSource.Kind="TripPin",Publish="TripPin.Publish"]
shared TripPin.Feed = Value.ReplaceType(TripPinImpl,type function (url as Uri.Type) as any);
TripPinImpl = (url as text) =>
let
source = Web.Contents(url,[ Headers = DefaultRequestHeaders ]),json = Json.Document(source)
in
json;
DefaultRequestHeaders = [
#"Accept" = "application/json",// column name and values only
#"Content-Type" = "application/json",// we only support v4
#"api-auth-id" = "my-api-id",#"api-auth-signature" = Crypto.CreateHmac(CryptoAlgorithm.SHA256,"my-api-key",**3rd argument (value as binary)**)
];
// Data Source Kind description
TripPin = [
Authentication = [
Anonymous = []
],Label = "TripPin Part 1 - OData"
];
// Data Source UI publishing description
TripPin.Publish = [
Beta = true,Category = "Other",ButtonText = { "TripPin OData","TripPin OData" }
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)