5 Replies Latest reply: Jun 9, 2017 9:31 AM by Eduardo DImperio RSS

    Help with Google Rest Connection

    Eduardo DImperio

      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

       

      RestConnectorMasterTable:

      SQL SELECT

        "Date",

        "__KEY__response_header",

        (SELECT

        "status",

        "balance",

        "lat",

        "lon",

        "accuracy",

        "address",

        "__FK_root"

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

        FROM JSON "_response_header" PK "__KEY__response_header"

        WITH CONNECTION ( 

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

        BODY "$(vRequestBody)"

      );

       

      startAt = startAt + pageSize;

       

      NEXT startAt;

       

      [Torre_Celular_Ind]:

      LOAD

        '$(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:

      // LOAD

      // ID_MODULE,

      // [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

       

       

      [_response_header]:

      LOAD

      [Date] AS [Date]

      RESIDENT RestConnectorMasterTable

      WHERE NOT IsNull([__KEY__response_header]);

       

      DROP TABLES RestConnectorMasterTable,_response_header, Torre_Celular_Ind, ;

       

       

      Next;