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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Take data from API with Queryuid

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 🙂

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

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,

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi ! 

Thanks it work perfectly now !


 

See you soon 😉

lbendlin
Super User
Super User

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,

 

Helpful resources

Announcements
Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.