Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Valued Contributor II

Help with Google Rest Connection

Hi everyone,

I reaally dont understand how this works, dont make any sense to me.

In my code i get all adress using rest connection, if i save storing one by one, that works fine, but if i try to save all in one single table i receive error in my second record. Any idea why?

For i_Module =1 to $(vNumDeModules)

let vIdModule = peek( 'ID_MODULE', $(i_Module) );

let vLac = peek( 'LAC_HEX', $(i_Module) );

let vCid = peek( 'CELLID_HEX', $(i_Module) );

let vMnc = peek( 'MNC', $(i_Module) );

Let vRequestBody ='';

Let vRequestBody = vRequestBody&'{"token":"96b1f7a718e6c8","radio":"gsm","mcc":724,"mnc":$(vMnc),"cells":[{"cid":$(vCid),"lac":$(vLac)}],"address": 1}';

let vRequestBody = replace(vRequestBody,'"', chr(34)&chr(34));

LIB CONNECT TO 'Unwired ';

  Let total = 0;


  Let totalfetched = 0;

  Let startAt = 0;

  Let pageSize = 100;


  for startAt = 0 to total step pageSize













  FROM (wrap on) "root" FK "__FK_root")

  FROM JSON "_response_header" PK "__KEY__response_header"


  URL "https://us1.unwiredlabs.com/v2/process.php",

  BODY "$(vRequestBody)"


startAt = startAt + pageSize;


NEXT startAt;




  '$(vIdModule)' AS ID_MODULE,

  [status]   AS [status],

  [balance]   AS [balance],

  [lat] AS [lat],

  [lon] AS [lon],

  [accuracy] AS [accuracy],

  [address] AS [address],

GeoMakePoint(Evaluate(lat), Evaluate(lon)) AS Local_Torre

RESIDENT RestConnectorMasterTable

WHERE NOT IsNull([__FK_root]);

STORE Torre_Celular_Ind into [lib://Dados/Unificado\Enderecos\Torre_Celular_Teste$(vIdModule).qvd] (qvd); //WORKS

// AUX:



// [status],

// [balance],

// [lat],

// [lon],

// [accuracy],

// [address],

// '$(vLac)' AS LAC_DEC, 

// '$(vCid)' AS CELLID_DEC,

// '$(vMnc)' AS MNC,

// Local_Torre

// RESIDENT [Torre_Celular_Ind]; // If i try concatenate all extracts from google i got error from second record



[Date] AS [Date]

RESIDENT RestConnectorMasterTable

WHERE NOT IsNull([__KEY__response_header]);

DROP TABLES RestConnectorMasterTable,_response_header, Torre_Celular_Ind, ;


5 Replies

Re: Help with Google Rest Connection

I don't know if it's only a typo but the drop tables has a comma at the end, before the semicolon.

If it's not the typo... loading from the generated qvd works?

Re: Help with Google Rest Connection

I'm not sure about the bucle for pagination, the total variable is 0 and I don't see any query to retrieve to total results that the query will return, so you can iterate through all pages.... anyway, I don't know much of this but when I had to do something similar these posts helped me:

Google Analytics with rest connector

Google analytics - authorization and pagination

Valued Contributor II

Re: Help with Google Rest Connection

Hi Ruben, thank you for the help, that was only a error when i copy and paste. That code works fine and i can store each loop in a qvd without problem. My problem is that i want to store all loops in one single qvd. For that i need to transform every loop in a line on a table, but when i do that i got error.

Re: Help with Google Rest Connection

Hi Eduardo, and what kind of error is returning?

Valued Contributor II

Re: Help with Google Rest Connection

Hi Ruben, sorry my delayed, it's been very rush over here.

I receive a colum Like This:

ID_MODULE           Adress

12345                Av. Paulista, 100

error                             -

error                             -

error                             -