Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
Hi !
I need to take data with several parameters present in the API response.
I write this code but he didn't work :
let
BaseUrl = "https://ecofac.nicoka.com/api/jobs/&hr__=1&limit=1000",
Token = "token",
EntitiesPerPage = 100,
GetJson = (Url) =>
let Options = [Headers=[ #"Authorization" = "Bearer " & Token ]],
RawData = Web.Contents(Url, [Headers=[Authorization="Bearer token"]]),
Json = Json.Document(RawData)
in Json,
GetTotalEntities = () =>
let Json = GetJson(BaseUrl),
Total = Json[total]
in Total,
GetUid = () =>
let Json = GetJson(BaseUrl),
Uid = Json[queryUid]
in Uid,
GetPage = (Index) =>
let Skip = "queryUid=" & Text.From(Uid) & "&" & "queryPage=" & Text.From(Index),
Url = BaseUrl & "&" & Skip,
Json = GetJson(Url),
Value = Json[data]
in Value,
GetUrl = (Index) =>
let Skip = "queryUid=" & Text.From(Uid) & "&" & "queryPage=" & Text.From(Index),
Url = BaseUrl & "&" & Skip
in Url,
EntityCount = List.Max({ EntitiesPerPage, GetTotalEntities() }),
PageCount = Number.RoundUp(EntityCount / EntitiesPerPage),
PageIndices = { 0 .. PageCount + 1 },
Uid = GetUid(),
URLs = List.Transform(PageIndices, each GetUrl(_)),
Pages = List.Transform(PageIndices, each GetPage(_)),
Entities = List.Union(Pages)
in
Entities
He return me that : "we were unable to authenticate with the information provided. Try again"
But when i just take data with simple code it's work like that code :
let
Source = Json.Document(Web.Contents("https://ecofac.nicoka.com/api/jobs/&hr__=1&limit=1000", [Headers=[Authorization="Bearer token"]]))
in
Source
I need your's helps
Thanks you for read and tried to help me 🙂
Solved! Go to Solution.
This part of the code is incorrect
GetJson = (Url) =>
let Options = [Headers=[ #"Authorization" = "Bearer " & Token ]],
RawData = Web.Contents(Url, [Headers=[Authorization="Bearer token"]]),
Json = Json.Document(RawData)
in Json,
Should be
GetJson = (Url) =>
let Options = [Headers=[ #"Authorization" = "Bearer " & Token ]],
RawData = Web.Contents(Url, Options),
Json = Json.Document(RawData)
in Json,
Hi !
Thanks it work perfectly now !
See you soon 😉
This part of the code is incorrect
GetJson = (Url) =>
let Options = [Headers=[ #"Authorization" = "Bearer " & Token ]],
RawData = Web.Contents(Url, [Headers=[Authorization="Bearer token"]]),
Json = Json.Document(RawData)
in Json,
Should be
GetJson = (Url) =>
let Options = [Headers=[ #"Authorization" = "Bearer " & Token ]],
RawData = Web.Contents(Url, Options),
Json = Json.Document(RawData)
in Json,
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 |
| User | Count |
|---|---|
| 11 | |
| 10 | |
| 7 | |
| 7 | |
| 6 |