Java Quickbase API addRecord() method usage

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered

Hello all,

I added quickbase.jar library to my Java Project.

Then I initialize a Quickbase client like this:

QuickBaseClient client = new QuickBaseClient("username", "password", "companyurl", "app_token");

Now, when I want to use the method:

client.addRecord(String dbid, HashMap recorddata)

I know which is my dbid, (App Management --> Show app Statistics)

But how can I build the HashMap with the different values I want to add to my table?

For example, suppose I have:

field_id_1, field_id_2, field_id_3

and I want to write : "Mom", "Dad", "Child" on this fields.

Many thanks in advance,

Gerardo


Photo of Gerardo Ariel

Gerardo Ariel

  • 0 Points

Posted 3 years ago

  • 0
  • 1
Photo of Gerardo Ariel

Gerardo Ariel

  • 0 Points
My first approach was to directly generate the http request and execute it. But I was having problems with the white spaces.

But finally I could make it work, this way:

String uri = "https://yourcompany.quickbase.com/db/yourtable?a=API_AddRecord";
                  + "&username=username"
                  + "&password=password!&includeRids=1"
                  + "&_fid_8=" + this.getCountry()
                  + "&_fid_9=" + this.getCity()
                  + "&apptoken=yourtoken";
      try {


      //Very important! : Replace ALL whitespaces from your String with "%20"        


String urlstring = uri.replaceAll(" ", "%20");

        URL url = new URL(urlstring);
        HttpURLConnection connection =(HttpURLConnection) url.openConnection();
        connection.setRequestMethod("GET");
        connection.setRequestProperty("Accept", "application/xml");

        // This line will generate an xml file, if you want to get the recordid, for example.
        InputStream xml = connection.getInputStream();
   
    I hope this can help other people, and if anyone would still like to provide a solution using Quickbase API, many thanks in advance.

Gerardo.