Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi guys,
I´ve been trying to make this work for some time.
The problem is that the API I´m trying to get data from only gives 100 records per call. It doesn´t provide any information on the return header or body so that I can use in the parameters of the Qlik Connector.
Here´s how the API works:
curl -X GET "https://bling.com.br/Api/v2/produtos/page=2/json/"
-G
-d "apikey={apikey}"
You need to keep changing pages until the API returns an error in this format:
{
"retorno": {
"erros": [
{
"erro": {
"cod": 14,
"msg": "A informacao desejada nao foi encontrada"
}
}
]
}
}
I simply don´t know how to implement this.
This is the Script Im using but it only retrieves the first 100 records:
LIB CONNECT TO 'Pedidos';
RestConnectorMasterTable:
SQL SELECT
"__KEY_retorno",
(SELECT
"__FK_pedidos",
"__KEY_pedidos",
(SELECT
"desconto",
"data",
"numero" AS "numero_u0",
"vendedor",
"totalprodutos",
"__KEY_pedido",
"__FK_pedido",
(SELECT
"nome",
"cnpj",
"cidade",
"uf",
"__FK_cliente"
FROM "cliente" FK "__FK_cliente"),
(SELECT
"__KEY_itens",
"__FK_itens",
(SELECT
"codigo",
"descricao",
"quantidade",
"valorunidade",
"descontoItem",
"un",
"__FK_item"
FROM "item" FK "__FK_item")
FROM "itens" PK "__KEY_itens" FK "__FK_itens"),
(SELECT
"__KEY_parcelas",
"__FK_parcelas",
(SELECT
"valor",
"dataVencimento",
"__KEY_parcela",
"__FK_parcela"
FROM "parcela" PK "__KEY_parcela" FK "__FK_parcela")
FROM "parcelas" PK "__KEY_parcelas" FK "__FK_parcelas")
FROM "pedido" PK "__KEY_pedido" FK "__FK_pedido")
FROM "pedidos" PK "__KEY_pedidos" FK "__FK_pedidos")
FROM JSON (wrap off) "retorno" PK "__KEY_retorno";
[cliente]:
LOAD [nome] AS [nome],
[cnpj] AS [cnpj],
[cidade] AS [cidade],
[uf] AS [uf],
[__FK_cliente] AS [pedido_id]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_cliente]);
[item]:
LOAD [codigo] AS [codigo],
[descricao] AS [descricao],
Replace([quantidade], '.', ',') AS [quantidade],
Replace([valorunidade], '.', ',') AS [valorunidade],
Replace([descontoItem], '.', ',') AS [descontoItem],
[un] AS [un],
[__FK_item] AS [item_id]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_item]);
[itens]:
LOAD [__KEY_itens] AS [item_id],
[__FK_itens] AS [pedido_id]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_itens]);
[parcela]:
LOAD Replace([valor], '.', ',') AS [valor],
[dataVencimento] AS [dataVencimento],
[__KEY_parcela] AS [parcela_id]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_parcela]);
[parcelas]:
LOAD [__KEY_parcelas] AS [parcela_id],
[__FK_parcelas] AS [pedido_id]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_parcelas]);
[pedido]:
LOAD Replace([desconto], '.', ',') AS [desconto_pedido],
[data] AS [data_pedido],
[numero_u0] AS [numero_pedido],
[vendedor] AS [vendedor],
Replace([totalprodutos], '.', ',') AS [totalprodutos],
[__KEY_pedido] AS [pedido_id]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_pedido]);
DROP TABLE RestConnectorMasterTable;
I would really appreciate any help on how to make it work. It´s probably simple, but I dont know.
same here!!!