2 Replies Latest reply: Oct 23, 2017 5:47 PM by cristian ivanoff RSS

    Rest Connector with variable as query parameter

    cristian ivanoff

      Hi All!

      Im working with the REST-connector. Which works fine! But, I need to change one of the query parameters every day. I need to send current date every time in the URL as a parameter and want to create a variable with this date. How can I accomplish this?

       

      Br

      Cris

        • Re: Rest Connector with variable as query parameter
          cristian ivanoff

          Hi,

          I created this script but it throws me an error "There is no open data connection. The generated URL is correct and I can copy it from the error message and paste it in the browser and it works. Any ideas what to do? How can I open the connection?

          Im using QlikSense Business Cloud.

           

          LET vStartDate = date(addmonths(Today(),-6),'D.M.YYYY');
          LET vEndDate = date(Today(),'D.M.YYYY');
          
          Let vURL = 'https://X/NordicSharesEOD/EODPricesDD?';
          LET vURL = vURL & '&token=GUSER-1f13bf6d-516e-4d0f-96fe-93011d77c791';
          LET vURL = vURL & '&todate=' & '$(vEndDate)';
          LET vURL = vURL & '&fromdate=' &  '$(vStartDate)';
          LET vURL = vURL & '&Accept=text/json';
          
          
          [DailySymbols]:
          SQL SELECT
          "symbol",
          "trading_date",
          "official_last",
          "paid_first",
          "paid_high",
          "paid_low",
          "volume_traded",
          "exchangename"
          FROM JSON (wrap on) "root" QDL
          WITH CONNECTION (
          URL "$(vURL)"
          )
          ;
          
          

           

          Any help or suggestion is appreciated.

          Br

          Cris

            • Re: Rest Connector with variable as query parameter
              cristian ivanoff

              This works fine. I created a dummy REST-connection to "open a connection". Then its modified by the "with connection".

               

              LIB CONNECT TO 'DummyGetConnection';
              
              LET vStartDate = date(addmonths(Today(),-6),'D.M.YYYY');
              LET vEndDate = date(Today(),'D.M.YYYY');
              
              Let vURL = 'https://X/NordicSharesEOD/EODPricesDD?';
              LET vURL = vURL & '&token=GUSER-31fbe38f-43d9-427f-8dfa-b6e82570';
              LET vURL = vURL & '&todate=' & '$(vEndDate)';
              LET vURL = vURL & '&fromdate=' &  '$(vStartDate)';
              LET vURL = vURL & '&Accept=text/json';
              
              [DailySymbols]:
              SQL SELECT 
              "symbol",
              "trading_date",
              "official_last",
              "paid_first",
              "paid_high",
              "paid_low",
              "volume_traded",
              "exchangename"
              FROM JSON (wrap on) "root" QDL
              WITH CONNECTION (
              URL "$(vURL)"
              )
              ;