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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
Kathir
Frequent Visitor

API JSON Codes

Kathir_0-1660619353256.png

 

hi, I need an help with the above code. I encountered an error: Expression.Error: We cannot convert a value of type Record to type Number. 

Need help on this please. 

6 REPLIES 6
lbendlin
Super User
Super User

Post a sanitized version of the returned JSON.

Sure thanks

 

Kathir_0-1660703969787.png

************************************************************************************************************

let
baseuri = "https://xxxx/devices/641524/stream-data-full",
initReq = Json.Document(Web.Contents(baseuri),[Headers=[Authorization="JWT "&GetToken()]]),
initData = initReq[results],
gather = (data as list, uri) =>

let
newOffset = Json.Document(Web.Contents("https://xxxx/devices/641524/stream-data-full"))[paging][next][after],
newUri = baseuri & "&after=" & newOffset,
newReq = Json.Document(Web.Contents(newUri)) ,
newdata = newReq[results] ,
data = List.Combine({data, newdata}),
check = if Table.Contains ( Record.ToTable(newReq) , [Name = "paging"] ) = true then @gather (data , newUri) else data
in check,

outputList = if Table.Contains ( Record.ToTable (initReq) , [Name = "paging"] ) = true then gather( initData , baseuri ) else initData ,
expand = Table.FromRecords(outputList)
in
expand

Your call result is a list, not a record. Replace Table.FromRecords with the appropriate list extractor.

Thanks but if i click goto error, its pointing to this line:

 

initReq = Json.Document(Web.Contents(baseuri),[Headers=[Authorization="JWT "&GetToken()]]),

Use "Bearer " instead of "JWT".

Sorry for the delayed reply. It still doesnt work. 

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

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.

Top Kudoed Authors