Expand all | Collapse all

API_ImportFromCVS functionality is not working

  • 1.  API_ImportFromCVS functionality is not working

    Posted 08-07-2018 11:11
    This is my API_ImportFromCVS function

    function uploadData(){
    console.log("Inside upload")

      if (patternFinalSku != "") {
      var url3 = "";
               url3 += "https://apollotyres.quickbase.com/db/bm7jkg5cj?act=API_ImportFromCSV";
                var qb_request = "";
                    qb_request += "<qdbapi>";
                    qb_request += "<records_csv><![CDATA[";
                    qb_request += patternFinalSku;
                    qb_request += "]]></records_csv>";
    qb_request += "<clist></clist>";  // Your destination fields.
                    qb_request += "<skipfirst>0</skipfirst>";
                    qb_request += "</qdbapi>";
                        type: "POST",
                        contentType: 'text/xml',
                        async: false,
                        url: url3,
                        dataType: "xml",
                        processData: false,
                        data: qb_request,
                        success: function (response) {

                            var num_recs_input = $("qdbapi num_recs_input ",response).text();
                           var  qb_recsadded = parseInt($("qdbapi num_recs_added ", response).text());
                        } // End success: function

    need to insert/update into table through API_ImportFromCVS but it is not working.I really need  help to resolve it.Above code column no 6 is unique key in the table

  • 2.  RE: API_ImportFromCVS functionality is not working

    Posted 08-30-2018 20:19
    If you place an AJAX call within a function your function should (1) take parameters and (2) return a promise.
    function uploadData(<parameters>){
      return $.ajax({...});
      .then(function(response) {
      //further codehere
    Other observations about your code:

    (1) You should simplify the code you post to the minimal size that demonstrates the same problem or exemplifies the same issue you are asking about. Posting a long clist only generates noise and makes it more unlikely you will get an answer.

    (2) Despite the API documentation and old answers in this forum, it is better to not supply the body of a POST as XML. See this sample code which calls API_ImportFromCSV without using an XML body:
      act: "API_ImportFromCSV",
      records_csv: "foo,bar,baz\n12,3\n4,5,6\n7,8,9",
      clist: "6.7.8"
    }).then(function(xml) {

    This is a general principle for almost all QuickBase APIs (unpublished and published). If the docs or source code you are looking at suggest you should send the POST body as XML:


    You can in fact just send the body as an object

    $.ajax(url, {
      action: "API_DoSomething:
      foo: "bar",
      baz: "quux"