Hi Tony - thanks for your contribution in this thread, this has helped me greatly in trying to connect to Zoho CRM. I'm trying to connect to Zoho CRM API and I am receiving an error after logging into Zoho through my custom connector, I hope you can help as my connector seems 90% complete, just missing the final step! (
code below).
Error message: [DataFormatError] We couldn't parse your query string as it was improperly formatted
// 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
//
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
];
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") }
];
Thank you!
------------------------------
Alexander Ferguson
------------------------------
Original Message:
Sent: Feb 05, 2019 08:59 AM
From: Tony McGovern
Subject: Zoho Desk connector to Power BI desktop
Elizabeth -- Zoho products allow applications to authenticate to their APIs using OAuth 2.0. This means you'll have to build a custom connector in Power BI.
My company uses Zoho products and I've built custom connectors in both Flow and Power BI to our data in Zoho Books, Zoho CRM, and Zoho Campaigns. I quickly looked at the API documentation for Zoho Desk and that API authenticates the same way as other Zoho products. And these APIs implement the "authorization code" grant type, which is a way for your application to request tokens from the authorization server.
Here's a sample custom connector for the DataWorld API, which also uses OAuth 2.0 authentication with an authorization code grant type. This other custom connector connects to Dropbox, which again, also uses OAuth 2.0 with the same grant type. (Both examples were created by developers on the Power BI product team.)
You can use these examples as templates for your Power BI custom connector to Zoho Desk.
Let me know if you run into any problems; I'm happy to help.
------------------------------
Tony McGovern
co-Founder & Data Scientist
em•data Inc.
tony@emdata.ai
(202) 594-6194
Original Message:
Sent: 02-04-2019 02:16 AM
From: Elizabeth Tachjian CPA
Subject: Zoho Desk connector to Power BI desktop
Hi,
Any ideas on how to connect Zoho Desk to Power bi Desktop? Not the same as Zoho CRM.
Cheers
Elizabeth
------------------------------
Elizabeth Tachjian CPA
Business Intelligence Dashboards Developer
Analytics Realtime
Melbourne [VIC]
0417457054
------------------------------