Forum Discussion

Re: Building URL to download CSV

Thanks for the response Blake. 

The URL calls work fine with my python automation but I'm open to a more robust option. I just need to automate pulling the table and saving it so I can manipulate the data. 

I've been looking here: https://help.quickbase.com/api-guide/gen_results_table.html#URL_Alternative

What would the API call look like? 

------------------------------
Edwin Reik
------------------------------

5 Replies

  • BlakeHarrison's avatar
    BlakeHarrison
    Qrew Captain
    I'd suggest you look into querying your Quickbase data directly utilizing the API. If you're working with Python, you can use the REST API here: https://developer.quickbase.com/operation/runQuery 

    Select the Code Samples tab and select Python from the drop-down and you'll get this code as an example query:

    import json
    import requests
    
    headers = {
      	'QB-Realm-Hostname': '{QB-Realm-Hostname}',
    	'User-Agent': '{User-Agent}',
    	'Authorization': '{Authorization}'
    }
    body = {}
    r = requests.post(
    'https://api.quickbase.com/v1/records/query', 
    headers = headers, 
    json = body
    )
    
    print(json.dumps(r.json(),indent=4))
    ​


    ------------------------------
    Blake Harrison
    bharrison@datablender.io
    DataBlender - Quickbase Solution Provider
    Atlanta GA
    404.800.1702 / http://datablender.io/
    ------------------------------
    • EdwinReik's avatar
      EdwinReik
      Qrew Member

      When I try this and print(r.url) I get the signin page. This is what happened when i tried to write my API request which i believe means I'm not getting in. 


      If you're able to support with building a URL that works I'd be satisfied. 

      'https://eagleview.quickbase.com/db/bpw3pr8nu?a=q&qid=31' + '&opts=csv' works when I'm signed in.

      'https://eagleview.quickbase.com/db/bpw3pr8nu?' + 'a=api_genresultstable&qid=31&options=csv&usertoken=SECRET' works when I'm not signed in, but downloads the wrong table! 

      'https://eagleview.quickbase.com/db/bpw3pr8nu?a=api_genresultstable&qid=31&usertoken=*secret*' (no mention of options csv) opens a page with the correct table present, but doesn't download the csv. This works when I'm not signed in.

      when I do the same as above but add '&options=csv' it downloads a CSV, but not the one that is being shown (same wrong one as mentioned above)... 

      What am I missing that can specify what the url is grabbing



      ------------------------------
      Edwin Reik
      ------------------------------

      • BlakeHarrison's avatar
        BlakeHarrison
        Qrew Captain
        If you use the last URL you mention and include the CSV option and it's downloading the wrong fields, I'm going to guess it's downloading the default fields for that table. Most likely, you'll need to include the 'clist' parameter to identify the fields you want to download.

        ------------------------------
        Blake Harrison
        bharrison@datablender.io
        DataBlender - Quickbase Solution Provider
        Atlanta GA
        404.800.1702 / http://datablender.io/
        ------------------------------