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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.