Forum Discussion
Anonymous
2 years agoNot applicable
Passing Variables into API URL - without preventing PBI Server dataset refresh
Hi, Needed to add a dynamic varaible to my API call used a function to pass the ID number and then pull the relevant field per ID - was very happy when it all seemed to work ok in desktop. Publishe...
- Anonymous2 years ago
Hi Anonymous,
Perhaps you can try to use option parameters in web connector if they help you to handle this scenario:
let GetProejct=(projectID as number) => let projectIDVariabl = projectID, root_url = "https://api.workguru.io", body = "{ ""ApiKey"": ""XXX"", ""Secret"": ""XXX"" }", tokenResponse = Web.Contents( root_url, [ Headers = [#"Content-Type" = "application/json"], RelativePath = "/api/ClientTokenAuth/Authenticate/api/client/v1/tokenauth", Content = Text.ToBinary(body) ] ), AccessToken = Json.Document(tokenResponse)[accessToken], projectResponse = Web.Contents( root_url, [ RelativePath = "/api/services/app/Project/GetProjectById", Headers = [#"content-type": "application/json", authorization = "Bearer " & AccessToken], Query = [ id = Number.ToText(projectIDVariabl), includeProductImages = "false", includeLineItemCustomFields = "true" ] ] ), GetGroups = Json.Document(projectResponse) in GetGroups in GetProejctRegards,
Xiaoxin Sheng
Anonymous
2 years agoNot applicable
Hi Anonymous,
Perhaps you can try to use option parameters in web connector if they help you to handle this scenario:
let
GetProejct=(projectID as number) =>
let
projectIDVariabl = projectID,
root_url = "https://api.workguru.io",
body = "{ ""ApiKey"": ""XXX"", ""Secret"": ""XXX"" }",
tokenResponse = Web.Contents(
root_url,
[
Headers = [#"Content-Type" = "application/json"],
RelativePath = "/api/ClientTokenAuth/Authenticate/api/client/v1/tokenauth",
Content = Text.ToBinary(body)
]
),
AccessToken = Json.Document(tokenResponse)[accessToken],
projectResponse = Web.Contents(
root_url,
[
RelativePath = "/api/services/app/Project/GetProjectById",
Headers = [#"content-type": "application/json", authorization = "Bearer " & AccessToken],
Query = [
id = Number.ToText(projectIDVariabl),
includeProductImages = "false",
includeLineItemCustomFields = "true"
]
]
),
GetGroups = Json.Document(projectResponse)
in
GetGroups
in
GetProejct
Regards,
Xiaoxin Sheng
Anonymous
2 years agoNot applicable
Thank you so much - that does the job nicely.
I just needed to update the colon to an equals in this line.
Headers = [#"content-type": "application/json", authorization = "Bearer " & AccessToken],