Intuit QuickBase Webinar: Solve More Problems - with QuickBase
Saving Time And Effort With QuickBase Api - Sergio Haro
-
Upload
intuit -
Category
Technology
-
view
7.877 -
download
7
description
Transcript of Saving Time And Effort With QuickBase Api - Sergio Haro
Saving Time and Effort with the QuickBase APISergio Haro
How does this help you?
Integration – Export/Import data from external sources (SQL / MS Access)
– Automate data entry
– Mash-ups (Add QuickBase data to other websites)
– See upcoming presentations ‘Connecting QuickBase with Databases’ and ‘Website Integration with QuickBase ‘
Custom Business Logic– Pull data to perform custom logic
– Insert calculated data back
Custom UI– Build your own app or website with QuickBase as your backing store
– Bypass the native UI to simplify or expand its capabilities
Jump-Start with SDK @ code.intuit.com
Browser-Based• JavaScript
- Good for db-pages (beware of cross-domain policy if using on external websites)- http://intuitlabs.com/apps/yql-and-intuit-quickbase (Getting around cross-domain)- See upcoming sessions ‘Magic Buttons’ and ‘Building a QuickBase Mobile Application’
Scripting Languages• Ruby
- http://www.ruby-lang.org- Object-oriented scripting language- Write scripts in your favorite text editor- See upcoming session ‘Integrating with QuickBase Web Services’
• VB- http://msdn.microsoft.com/en-us/vbasic/- Build VB scripts in Visual Studio (Windows only)
• Perl- http://www.perl.org/- Write scripts in your favorite text editor
General Programming Languages• C#
- http://msdn.microsoft.com/en-us/vcsharp/- Build C#apps in Visual Studio (Windows only)
• Java- http://java.sun.com/- Build Java apps with your favorite IDE (Eclipse, NetBeans, etc)
How does it work?
You QuickBase
HTTP (GET or POST)
XML
HTTP Request
• URLPOST http://www.quickbase.com/db/main
• HeadersHost: www.quickbase.comUser-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Language: en-us,en;q=0.5Accept-Encoding: gzip,deflateAccept-Charset: UTF-8,*Keep-Alive: 300Connection: keep-alive
HTTP Request
• URLPOST http://www.quickbase.com/db/main
• HeadersHost: www.quickbase.comUser-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Language: en-us,en;q=0.5Accept-Encoding: gzip,deflateAccept-Charset: UTF-8,*Keep-Alive: 300Connection: keep-alive
• Bodyfoobar=true&type=unknown
Components of an API Call
1. Scope• Set in the URL• Dependent on Action
Components of an API Call
1. Scope
2. Action to perform
3. Parameters for action
Scope
1. Main– https://www.quickbase.com/db/main
2. App– https://www.quickbase.com/db/{app_id}
3. Table– https://www.quickbase.com/db/{table_id}
Components of an API Call
1. Scope
2. Action to perform• Set in the URL, Headers, or Body
Action
• HeaderQUICKBASE-ACTION: API_AddRecord
• URLQuery string: “a=API_AddRecord”https://www.quickbase.com/db/b4ds?a=API_AddRecord
• Body <qdbapi>
<action>API_AddRecord</action></qdbapi>
Components of an API Call
1. Scope
2. Action to perform
3. Parameters for action• Set in the URL and/or Body• Dependent on action• Encoded as XML or Form
Parameters for Action (API_FindDBByName)
Parameter: Valuedbname: Test APIticket: kiedzc4rtab8gqdr6apptoken: asfkhlk35rnl4nn
XML Parameters
<qdbapi><dbname>test API</dbname><ticket>kiedzc4rtab8gqdr6</ticket><apptoken>asfkhlk35rnl4nn<apptoken>
</qdbapi>
XML Parameters
• URLPOST http://www.quickbase.com/db/main
• HeadersContent-Type: application/xmlContent-Length: 76QUICKBASE-ACTION: API_FindDBByName
• Body<qdbapi>
<dbname>test API</dbname><ticket>kiedzc4rtab8gqdr6</ticket><apptoken>asfkhlk35rnl4nn<apptoken>
</qdbapi>
Form Parameters
dbname=test%20API&ticket=kiedzc4rtab8gqdr6&apptoken=asfkhlk35rnl4nn
Form Parameters
• URLPOST http://www.quickbase.com/db/main
• HeadersContent-Type: application/x-www-form-urlencodedContent-Length: 76QUICKBASE-ACTION: API_FindDBByName
• Body dbname=test%20API&ticket=kiedzc4rtab8gqdr6&apptoken=asfkhlk35rnl4nn
GET Request
• URLPOST http://www.quickbase.com/db/main?a=API_FindDBByName&dbname=test%20API&ticket
=kiedzc4rtab8gqdr6&apptoken=asfkhlk35rnl4nn
• HeadersContent-Type: text/html
• Body
What will I get back?
<?xml version="1.0" ?><qdbapi><action>API_FindDBByName</action><errcode>0</errcode><errtext>No error</errtext><dbid>57pa5vjf</dbid><dbname>Test API</dbname>
</qdbapi>
Example
09-15 02:49:58.550 I366aswux2 Process: Req: 0.013 [LB: 0.003 WS: 0.004 Q: 0.004] Bytes=[R: 0 W: 24957] Uid=56752832 OP=/db/main
• Date• Time• Request ID• Logging Function• Request Time• Load Balancer time• App Server time• Queue time• Bytes Read• Bytes Written• User ID• URL
Example
Main Script Tasks:1. Get lines from input2. Parse lines3. Calculate Statistics4. Upload Statistics
Example - Create Request
string action; // Get POST data string data = addRecord(stats, out action);
// Create HTTP Request string url = “http://www.quickbase.com/db/” + dbid; HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
// Set HTTP Headers webRequest.Method = "POST"; webRequest.ContentType = "application/xml"; webRequest.Headers.Add("QUICKBASE-ACTION", action);
// Write Body byte[] postBytes = Encoding.ASCII.GetBytes(data); webRequest.ContentLength = postBytes.Length; Stream postStream = webRequest.GetRequestStream(); postStream.Write(postBytes, 0, postBytes.Length); postStream.Close();
Example - Create Body
// Create Root Document action = "API_AddRecord";
XmlDocument doc = new XmlDocument(); XmlElement root = doc.CreateElement("qdbapi");
XmlElement child;
// Add Field child = doc.CreateElement("field"); child.SetAttribute("fid", "6"); child.InnerText = stats.webServerAverage.ToString(); root.AppendChild(child);
…
// Add App token child = doc.CreateElement("apptoken"); child.InnerText = "ye6wbdh59j7rbsf3txbd679ha7"; root.AppendChild(child);
doc.AppendChild(root);
StringWriter sw = new StringWriter(); XmlTextWriter tx = new XmlTextWriter(sw); doc.WriteTo(tx);
return sw.ToString();
Example - Create Request
string action; // Get POST data string data = addRecord(stats, out action);
// Create HTTP Request string url = “http://www.quickbase.com/db/” + dbid; HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
// Set HTTP Headers webRequest.Method = "POST"; webRequest.ContentType = "application/xml"; webRequest.Headers.Add("QUICKBASE-ACTION", action);
// Write Body byte[] postBytes = Encoding.ASCII.GetBytes(data); webRequest.ContentLength = postBytes.Length; Stream postStream = webRequest.GetRequestStream(); postStream.Write(postBytes, 0, postBytes.Length); postStream.Close();
Example - Create Request
string action; // Get POST data string data = addRecord(stats, out action);
// Create HTTP Request string url = “http://www.quickbase.com/db/” + dbid; HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
// Set HTTP Headers webRequest.Method = "POST"; webRequest.ContentType = "application/xml"; webRequest.Headers.Add("QUICKBASE-ACTION", action);
// Write Body byte[] postBytes = Encoding.ASCII.GetBytes(data); webRequest.ContentLength = postBytes.Length; Stream postStream = webRequest.GetRequestStream(); postStream.Write(postBytes, 0, postBytes.Length); postStream.Close();
Example - Create Request
string action; // Get POST data string data = addRecord(stats, out action);
// Create HTTP Request string url = “http://www.quickbase.com/db/” + dbid; HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
// Set HTTP Headers webRequest.Method = "POST"; webRequest.ContentType = "application/xml"; webRequest.Headers.Add("QUICKBASE-ACTION", action);
// Write Body byte[] postBytes = Encoding.ASCII.GetBytes(data); webRequest.ContentLength = postBytes.Length; Stream postStream = webRequest.GetRequestStream(); postStream.Write(postBytes, 0, postBytes.Length); postStream.Close();
Resources
• Developer Resources– http://quickbase.intuit.com/developer/
• API Guide (old)– https://www.quickbase.com/up/6mztyxu8/g/rc7/en/
API’S YOU SHOULD KNOW
API_Authenticate
Parameters:
– username– password
API_AddRecord
Parameters:
– Field (name=“Field Name” or fid=“14”)– apptoken– ticket
API_EditRecord
Parameters:
– rid– Field (name=“Field Name” or fid=“14”)– apptoken– ticket
API_DoQuery
Parameters:
– query/qid/qname– clist– slist– apptoken– ticket