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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
EthanMc
New Member

M Code functions not recognised by other query

So I am using 1 function to gather my access token, 1 which builds the framework of the API and the final one which puts the 2 together with query parameters and returns the data. on the 3rd function, I am getting this "Expression.Error: The name 'X/Y' wasn't recognized. Make sure it's spelled correctly." I get the error for both steps (referencing both functions) on query 3. They have the fx symbol suggesting they are set up as functions also. I am sure they are spelt correctly, can anyone help?

Queries below, (Client details and URLS redacted)

 

Query1

let
GetAccessToken = () =>
let
url = "https://login.serverdata.net/user/connect/token",
body = [
grant_type = "client_credentials",
client_id = "XYZ",
client_secret = "ZYX",
scope = "api.some.scope.ting"
],
headers = [#"Content-Type" = "application/x-www-form-urlencoded"],
source = Json.Document(Web.Contents(url, [Headers=headers, Content=Text.ToBinary(Uri.BuildQueryString(body))]))
in
source[access_token]
in
GetAccessToken

 

Query2

let
GetCallDetails = (accessToken, dateFrom, dateTo) =>
let
url = "https://api.call.data/analytics/calls/call/detail",
body = [dateFrom = dateFrom, dateTo = dateTo],
headers = [#"Content-Type" = "application/json", #"Authorization" = "Bearer " & accessToken],
source = Json.Document(Web.Contents(url, [Headers=headers, Content=Text.ToBinary(Json.FromValue(body))]))
in
source
in
GetCallDetails

 

Query3

let
accessToken = GetAccessToken(),
callDetails = GetCallDetails(accessToken, "2023-06-01T00:00:00.000Z", DateTime.ToText(DateTime.LocalNow()))
in
callDetails

1 ACCEPTED SOLUTION
ppm1
Solution Sage
Solution Sage

In your case, "Query 1" returns the access token, so you'll need to reference the query name and not the function within it.

 

Pat

Microsoft Employee

View solution in original post

1 REPLY 1
ppm1
Solution Sage
Solution Sage

In your case, "Query 1" returns the access token, so you'll need to reference the query name and not the function within it.

 

Pat

Microsoft Employee

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors