Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
pedrovillanueva
Regular Visitor

Error with connect zoho crm

Login Failed [Dataformat.error] we couldn't parse your query string because it was impropely formatted

 

// This file contains your Data Connector logic
section ZohoCrm;

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

client_id ="xxxxxxxxxxxx";
client_secret = "xxxxxxxxxxxx";

redirect_uri = "https://accounts.zoho.com/redirect";


windowWidth = 800;

windowHeight = 800;


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

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

navTable =Web.Contents("https://www.zohoapis.com/crm/v2/xxxx"),
Tracelog=Diagnostics.Trace(TraceLevel.Information,"Zohocrm",()=>navTable,true)
in

navTable;


// Data Source Kind description
ZohoCrm = [
Authentication = [
// enable both OAuth and Key based auth

OAuth = [

StartLogin = StartLogin,

FinishLogin = FinishLogin,

Refresh=Refresh

]

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

// Data Source UI publishing description
ZohoCrm.Publish = [
Beta = true,
Category = "Other",
ButtonText = { Extension.LoadString("ButtonTitle"), Extension.LoadString("ButtonHelp") },
LearnMoreUrl = "https://powerbi.microsoft.com/",
SourceImage = ZohoCrm.Icons,
SourceTypeImage = ZohoCrm.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

];

Label = Extension.LoadString("DataSourceLabel");
// 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");

ZohoCrm.Icons = [
Icon16 = { Extension.Contents("ZohoCrm16.png"), Extension.Contents("ZohoCrm20.png"), Extension.Contents("ZohoCrm24.png"), Extension.Contents("ZohoCrm32.png") },
Icon32 = { Extension.Contents("ZohoCrm32.png"), Extension.Contents("ZohoCrm40.png"), Extension.Contents("ZohoCrm48.png"), Extension.Contents("ZohoCrm64.png") }
];

1 REPLY 1
v-kelly-msft
Community Support
Community Support

Hi  @pedrovillanueva ,

 

Extension.Contents function is usually used with .txt  format,check the blog below:

https://blog.crossjoin.co.uk/2017/11/15/the-extension-contents-m-function/

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors