Forum Discussion

CarlosCarlos's avatar
CarlosCarlos
Qrew Assistant Captain
6 years ago

API_ImportfromCSV doing nothing

Hi all!

I'm trying to run this API_ImportfromCSV but it's getting me nowhere. 
I'd appreciate some help as I've been stuck with it for many hours, and haven't gotten to my error.

https://(DOMAIN).quickbase.com/db/(TABLE)?a=API_ImportFromCSV&usertoken=(USERTOKEN)&apptoken=(APPTOKEN)&records_csv=Guia,34168,102999&clist=6&skipfirst=1
This should create new records in the table when the API is run. 
Added "apptoken" as the API returned an error even when using usertokens.
Everything seems to be fine, but the reply is: 

<qdbapi>
<action>API_ImportFromCSV</action>
<errcode>0</errcode>
<errtext>No error</errtext>
<num_recs_input>0</num_recs_input>
<num_recs_added>0</num_recs_added>
<num_recs_updated>0</num_recs_updated>
<num_recs_unchanged>0</num_recs_unchanged>
</qdbapi>


Nothing seems to happen!
I've tried doing this from google scripts, as I want to automate the import but this also doesn't seem to work.. I have the values I need for the CSV in an array, which i'm joining using
    var csvString = "Guia," + arregloGuias.join(",\n");      var url = baseURL + table + "?a=API_ImportFromCSV" + usr_token + apptoken;
  var options =
      {
        "method"  : "POST",
        "records_csv" : csvString,
        "clist" : "6",
        "skipfirst": "1"
      };
  Logger.log(url + options);
  var result = UrlFetchApp.fetch(url, options);
  Logger.log(result);

The result is the same
<?xml version="1.0" ?>
<qdbapi>
<action>API_ImportFromCSV</action>
<errcode>0</errcode>
<errtext>No error</errtext>
<num_recs_input>0</num_recs_input>
<num_recs_added>0</num_recs_added>
</qdbapi>



Appreciate any help!!

Thanks!




7 Replies

  • So I can't say for sure about your google scripts example without seeing your array for arregloGuias - but in your first URL example - you have the skipfirst=1 meaning you're skipping the first row, but you only have 1 row so it's not going to import anything. The skipfirst is usually intended if you have headers. Remove that from your first example and that should get you moving

    Side note - your clist only has one field (clist=6) but it looks like you're trying to import to 3 fields (records_csv=Guia,34168,102999). You'll want to make your clist have 3 field IDs to match
    • CarlosCarlos's avatar
      CarlosCarlos
      Qrew Assistant Captain
      Hi Chayce,
      I actually have a single column (Guia) that is being imported, and the 2 values there (34168 and 102999) are 2 records that should be created, importing into fid_6. Though currently only 2 values/new records, this could be any number of records, but always a single value will create them.

      The array would look something like [34168,102999] with N number of values possibly in there. I'm manually adding the "Guia" header, though that could be removed. 
    • ChayceDuncan2's avatar
      ChayceDuncan2
      Qrew Cadet
      Ah - now I see what you're doing. So then same reason - different explanation from my first comment. Since its an importFromCSV - you have to force it to understand a new row. By doing value,value 2,value 3 as comma delimited - your browser just treats that as 1 row. 

      So you'll want something like this:

      "https://yourrealm.quickbase.com/db/yourtable?a=API_ImportFromCSV&records_csv=Guia" & URLEncode("\n") & "row1" & URLEncode("\n") & "row2" & "clist=12"

      The URLEncode if you're in QB will force it to interpret them as new lines. You can leave or remove the skipfirst at that point

    • CarlosCarlos's avatar
      CarlosCarlos
      Qrew Assistant Captain
      Well that seems to have done the trick nicely!!


      I'd like to get it to work without using the URL alternative, basically so an unlimited number of records could be posted at any given time, but this will definitely do for now! 

      Thanks a lot!