Forum Discussion
CarlosWagner
5 years agoFrequent Visitor
API Json REST - com tabela de registros infinitos
Estou com um problema ao requisitar um endereço URL E Estou seguindos os passos: 1º Criei uma tabela com os endereços; startIndex = 1 & count = 100
startIndex = 101 & ...
- 5 years ago
The documentation seems ok, but as you have noticed it only returns 500 (well, 460) rows. Can you talk to someone at that company to ask them for an exampe of how they use the API? I think there are other parameters, or some other part of the process that we are missing.
EDIT: Try this version, this seems to work :
let Source = List.Generate(()=>1, each _ < 5000, each _+500), #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error), #"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"Column1", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Data", each Json.Document(Web.Contents("http://novaindy105186.protheus.cloudtotvs.com.br:4040/rest/RTPWBI04?startindex=" & Text.From([Column1]) & "&count=" & Text.From([Column1]+499)))), #"Expanded Data" = Table.ExpandRecordColumn(#"Added Custom", "Data", {"data"}, {"Data.data"}), #"Expanded Data.data" = Table.ExpandListColumn(#"Expanded Data", "Data.data"), #"Expanded Data.data1" = Table.ExpandRecordColumn(#"Expanded Data.data", "Data.data", {"id", "Filial", "Item", "Produto", "DescProduto", "TipoProduto", "UM", "Quantidade", "VlrPrecoVenda", "VlrUnitario", "VlrDesconto", "VlrTotal", "Custo", "TipoSaida", "NPedido", "Cliente", "Loja", "Nome", "Doc", "Serie", "TipoDoc", "DtEmissao", "CodGrupo", "DescGrupo", "CodTabPreco", "Vendedor"}, {"id", "Filial", "Item", "Produto", "DescProduto", "TipoProduto", "UM", "Quantidade", "VlrPrecoVenda", "VlrUnitario", "VlrDesconto", "VlrTotal", "Custo", "TipoSaida", "NPedido", "Cliente", "Loja", "Nome", "Doc", "Serie", "TipoDoc", "DtEmissao", "CodGrupo", "DescGrupo", "CodTabPreco", "Vendedor"}) in #"Expanded Data.data1"In my opinion the "count" parameter is wrongly named in their API. It should be called "endIndex".
lbendlin
5 years agoSuper User
Shouldn't your count always be 100? You can use a recursive function (if the data isn't too big) and exit once the returned number of records from a call is less than 100.
- CarlosWagner5 years agoFrequent Visitor
Eu entendi, obrigado!
Como faço para a atualização funcionar no serviço online?