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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live 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
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.