How to programmatically connect to QuickBooks Online Edition (QBOE)

Here are all the steps to connect to QuickBooks Online Edition (QBOE) and retrieve some data.  Special thanks to Keith Palmer for his comments, answers, and his Consolibyte Solutions Website which really helped me get this working.  Originally posted on StackOverflow: Connecting an ASP.NET application to QuickBooks Online Edition.

  1. Register your application at http://appreg.quickbooks.com. This will give you your App ID and Application Name. Use these settings:
    • Target Application: QBOE
    • Environment: Production
    • Application Type: Desktop
      • (using Desktop made things much easier as far as not needing certificates)
    • A verification key will be sent to your email address which you need to enter on page 2 of this wizard.
  2. Set up your QBOE Connection. Once you finish registering your application in Step 1, you will then have an Application ID. Use this ID in the url below to set up your QBOE Connection:
    • https://login.quickbooks.com/j/qbn/sdkapp/confirm?serviceid=2004&appid=APP_ID
    • NOTE: Make sure to replace APP_ID in the above url with the Application ID that was created when you registered your application.
    • The wizard will take you through the following steps:
      1. Specifying a name for your connection.
      2. Granting Access Rights - I gave All Accounting rights since this was easiest.
      3. Specify Login Security - I turned Login Security Off. This is important since it makes submitting the xml to the QBOE much easier since you do not need to get a session ticket for each user.
      4. You will then be given a Connection Key.
  3. At this point you now have the 3 important pieces of information in order to gain access to your QuickBooks Online Edition (QBOE) account.
    • Application Name
    • Application ID
    • Connection Key
  4. Post the XML to QBOE with the 3 pieces of access information and the actual request into your QBOE database. Here is sample c# code that will post to the QBOE gateway. This will return all customers in your QuickBooks database. Make sure to update the xml below with your Application Name, Application ID, and Connection Key.

string requestUrl = null;
requestUrl = "
https://apps.quickbooks.com/j/AppGateway";

HttpWebRequest WebRequestObject = null;
StreamReader sr = null;
HttpWebResponse WebResponseObject = null;
StreamWriter swr = null;

try
{
    WebRequestObject = (HttpWebRequest)WebRequest.Create(requestUrl);
    WebRequestObject.Method = "POST";
    WebRequestObject.ContentType = "application/x-qbxml";
    WebRequestObject.AllowAutoRedirect = false;
string post = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<?qbxml version=""6.0""?>
<QBXML>
<SignonMsgsRq>
<SignonDesktopRq>
<ClientDateTime>%%CLIENT_DATE_TIME%%</ClientDateTime>
<ApplicationLogin>APPLICATION_LOGIN</ApplicationLogin>
<ConnectionTicket>CONNECTION_TICKET</ConnectionTicket>
<Language>English</Language>
<AppID>APP_ID</AppID>
<AppVer>1</AppVer>
</SignonDesktopRq>
</SignonMsgsRq>
<QBXMLMsgsRq onError=""continueOnError"">
<CustomerQueryRq requestID=""2"" />
</QBXMLMsgsRq>
</QBXML>";

    post = post.Replace("%%CLIENT_DATE_TIME%%", DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss"));
    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.LoadXml(post);
    post = xmlDoc.InnerXml;
    WebRequestObject.ContentLength = post.Length;
    swr = new StreamWriter(WebRequestObject.GetRequestStream());
    swr.Write(post);
    swr.Close();
    WebResponseObject = (HttpWebResponse)WebRequestObject.GetResponse();
    sr = new StreamReader(WebResponseObject.GetResponseStream());
    string Results = sr.ReadToEnd();
    }
finally
    {
        try
        {
            sr.Close();
        }
        catch
        {
        }

    try
    {
        WebResponseObject.Close();
        WebRequestObject.Abort();
    }
    catch
    {
    }
}

 

  • Couple things to note:
    • The qbxml version needs to be 6.0 (even though the IDN Unified On-Screen Reference shows 7.0).
    • The onError="continueOnError" attribute is required.
    • Setting the WebRequestObject.ContentLength property is required.
    • Content Type needs to be "application/x-qbxml".
    • And finally I received many "The remote server returned an error: (400) Bad Request." exceptions which were not helpful at all but in the end I was able to trace them to something wrong with the xml. So if you get this exception look to your xml as the source of the problem.


Published 04 October 2009 09:17 PM by Jeff Widmer

Comments

# Twitter Trackbacks for How to programmatically connect to QuickBooks Online Edition (QBOE) - Jeff Widmer's Blog [asp.net] on Topsy.com said on 05 October, 2009 12:12 PM

Pingback from  Twitter Trackbacks for                 How to programmatically connect to QuickBooks Online Edition (QBOE) - Jeff Widmer's Blog         [asp.net]        on Topsy.com

# Dmitriy Zasyatkin said on 01 April, 2010 04:10 PM

Thanks so much sharing Jeff. This is by far the easiest setup and best tutorial on QBOE integration.

# Jordan said on 24 May, 2010 01:43 PM

Great tutorial... Any chance on showing how to connect via Security turned on... Using session ticket.. ?

Thanks! ..

# Jeff Widmer said on 25 May, 2010 06:26 AM

Hi Jordan,

I probably won't be able to do that anytime soon.  But in general you would need an extra request at the beginning where you would get the session ticket.  Once you get the xml back from QBOE with the session ticket, parse that XML, and then make all of your other requests with it in the correct xml node (you will need to look up exactly where it belongs in any future request).

-Jeff

# tom donino said on 30 August, 2011 06:34 AM

Jeff, the link on step 2 where you add your app id DOES NOT take me to a setup wizard it takes me here

qbo.intuit.com/.../login

any thoughts how to get set up now?

my email is antilleslp at hotmail.com

# Jeff Widmer said on 02 September, 2011 02:23 PM

Hi Tom,

Looks like Intuit has updated their site and the link I have is no longer valid.  I haven't had a chance to look into this yet but the next time I get into setting up a Quickbooks Online app I will update this post with the new url (and possibly updated process).

-Jeff

# Joseph Reema said on 19 October, 2011 05:57 AM

Hi Tom,

you have to click continue and from the next page click continue after verifying Connection Name. Connection Name should be matching with App Desc of your application(App Desc shown after registering your application with IDN).  From the next page select Access Rights:All Accounting , and finaly from the last page  Login Security: select NO option to skip session ticket request in BeginSession().

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Search

Go

This Blog

News

Syndication