首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Zoho CRM API到Power BI连接器

Zoho CRM API到Power BI连接器
EN

Stack Overflow用户
提问于 2020-06-02 15:39:06
回答 1查看 419关注 0票数 0

我正在尝试连接到Zoho CRM API以将数据导入到PowerBI中,但通过我的自定义连接器登录到Zoho后收到一个错误,我希望您能帮助我,因为我的连接器似乎完成了90%,只是错过了最后一步!(代码如下)。

错误消息: DataFormatError我们无法解析您的查询字符串,因为它的格式不正确

代码语言:javascript
复制
// This file contains your Data Connector logic
section Zoho_Connector___V1.1;

// TODO: add your client id and secret to the embedded files

client_id = "XXXXX";

client_secret = "XXXXXX";

redirect_uri = "https://oauth.powerbi.com/views/oauthredirect.html";

windowWidth = 800;

windowHeight = 800;

//Oauth base url for

OAuthBaseUrl = "https://accounts.zoho.eu/oauth/v2/auth?";


[DataSource.Kind="Zoho_Connector___V1.1", Publish="Zoho_Connector___V1.1.Publish"]
shared Zoho_Connector___V1.1.Contents = () =>
let

navTable = Web.Contents("https://www.zohoapis.eu/crm/v2/Leads")

in

navTable;


// Data Source Kind description
Zoho_Connector___V1.1 = [
Authentication = [
// enable both OAuth and Key based auth

OAuth = [

StartLogin = StartLogin,

FinishLogin = FinishLogin,

Refresh=Refresh

]

],
Label = Extension.LoadString("DataSourceLabel")
];

// Data Source UI publishing description
Zoho_Connector___V1.1.Publish = [
Beta = true,
Category = "Other",
ButtonText = { Extension.LoadString("ButtonTitle"), Extension.LoadString("ButtonHelp") },
LearnMoreUrl = "https://powerbi.microsoft.com/",
SourceImage = Zoho_Connector___V1.1.Icons,
SourceTypeImage = Zoho_Connector___V1.1.Icons
];

// OAuth2 flow definition

//


// Start Login thorugh OAUTH
StartLogin = (resourceUrl, state, display) =>

let

AuthorizeUrl = OAuthBaseUrl & Uri.BuildQueryString([

scope = "ZohoCRM.modules.all",

client_id = client_id,

redirect_uri = redirect_uri,

response_type = "code",

state = state,

access_type = "online"])

in

[

LoginUri = AuthorizeUrl,

CallbackUri = redirect_uri,

WindowHeight = windowHeight,

WindowWidth = windowWidth,

Context = null

];

// Finish Login through OAUTH

FinishLogin = (context, callbackUri, state) =>

let

Parts = Uri.Parts(callbackUri)[Query]

in

TokenMethod(Parts[code], "authorization_code");



TokenMethod = (code, grant_type) =>

let

Response = Web.Contents(OAuthBaseUrl & "/token", [

Content = Text.ToBinary(Uri.BuildQueryString([

grant_type = "authorization_code",

client_id = client_id,

client_secret = client_secret,

redirect_uri = redirect_uri,

code = code
]
)),

Headers=[#"Content-type" = "application/x-www-form-urlencoded",#"Accept" = "application/json"]]),

Parts = Json.Document(Response)

in

Parts;



Refresh = (resourceUrl, refresh_token) => TokenMethod(refresh_token, "refresh_token");

Zoho_Connector___V1.1.Icons = [
Icon16 = { Extension.Contents("Zoho_Connector___V1.116.png"), Extension.Contents("Zoho_Connector___V1.120.png"), Extension.Contents("Zoho_Connector___V1.124.png"), Extension.Contents("Zoho_Connector___V1.132.png") },
Icon32 = { Extension.Contents("Zoho_Connector___V1.132.png"), Extension.Contents("Zoho_Connector___V1.140.png"), Extension.Contents("Zoho_Connector___V1.148.png"), Extension.Contents("Zoho_Connector___V1.164.png") }
];

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2020-06-07 02:54:05

YOu您的代码中有bug (可能还有更多),请查看此变量

代码语言:javascript
复制
OAuthBaseUrl = "https://accounts.zoho.eu/oauth/v2/auth?";

您的exchange code url是

代码语言:javascript
复制
OAuthBaseUrl & "/token"

请将焦点放在OauthBaseUrl末尾的问号上,它将解决此问题

代码语言:javascript
复制
https://accounts.zoho.eu/oauth/v2/auth?/token

但它应该是

代码语言:javascript
复制
https://accounts.zoho.eu/oauth/v2/token

我的另一个建议是在代码中添加错误处理和日志。它将帮助你准确地理解问题。您还可以获取响应头和状态,以确定潜在问题

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62147086

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档