Jood Kastero
New Member
- Joined
- Dec 3, 2020
- Messages
- 1
- Office Version
- 365
- Platform
- Windows
Dears,
I need your help please in my issue," I'm new to DAX and I have tried many ways in this issue and nothing work with me", simply what I'm trying to do is to loop over my API to get the customer details. the API limit is 50 per page I manage to retrieve one page but when I wrote the script I got an error that Converts a value of type Record to type Text.
the call for one page it retrieves 3 things (data, links and meta) I want to loop whenever I have pages or new pages to get the data and store it in one table then expand that table.
and when this code run the issue appears in this section:
and this is the error:
Expression.Error: We cannot convert a value of type Record to type Text.
Details:
Value=[Record]
Type=[Type]
Any Idea please on this
I need your help please in my issue," I'm new to DAX and I have tried many ways in this issue and nothing work with me", simply what I'm trying to do is to loop over my API to get the customer details. the API limit is 50 per page I manage to retrieve one page but when I wrote the script I got an error that Converts a value of type Record to type Text.
the call for one page it retrieves 3 things (data, links and meta) I want to loop whenever I have pages or new pages to get the data and store it in one table then expand that table.
Power Query:
let
BaseUrl = Json.Document(Web.Contents("https://api.XXXXXXXXXXXX\Customer.com",
[
Headers=
[
Authorization="Bearer XXXXXXXXXXXX",
Accept="application/json",
#"Content-Type"="application/json"
]
] )
),
EntitiesPerPage = 50,
Url = BaseUrl,
GetJson = (Url) =>
let
RawData = Web.Contents(Url),
Json = Json.Document(RawData)
in
Json,
GetTotalCount = () =>
let
Json = GetJson(Url),
Entities = Json[Count]
in
Entities,
EntityCount = GetTotalCount(),
PageCount = Number.RoundUp(EntityCount / EntitiesPerPage),
PageIndex = { 1 .. PageCount},
GetPage = (PageIndex) =>
let
PageUrl = BaseUrl & "page=" & Text.From(PageIndex),
Json = GetJson(PageUrl),
Value = Json[Customer]
in
Value,
GetUrl = (PageIndex) =>
let
PageNum = "page=" & Text.From(PageIndex),
PageUrl = BaseUrl & PageNum
in
PageUrl,
Urls = List.Transform(PageIndex, each GetUrl(_)),
Pages = List.Transform(PageIndex, each GetPage(_)),
DataList = List.Union(Pages),
TableFromList = Table.FromList(DataList, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
#"TableFromList"
and when this code run the issue appears in this section:
Power Query:
GetJson = (Url) =>
let
RawData = Web.Contents(Url),
Json = Json.Document(RawData)
in
Json,
and this is the error:
Expression.Error: We cannot convert a value of type Record to type Text.
Details:
Value=[Record]
Type=[Type]
Any Idea please on this