Topic: API addCheck

I have a project to simply create checks in QB.  I have used bill payment check in the past with no problem but can't get addCheck to work.  I even tried to use test_check.php that is in the dev folder and keep getting the same result. 

The log shows:

Attempting to handle error: 0x80040400, QuickBooks found an error when parsing the provided XML text stream.

The msg in qb_queue

Unverified... no requestID attribute in XML stream.

QBXML

<?xml version="1.0" encoding="utf-8"?>
    <?qbxml version="{$version}"?>
        <QBXML>
            <QBXMLMsgsRq onError="{$onerror}">
                <CheckAddRq>
                    <CheckAdd>
                        <PayeeEntityRef>
                            <FullName>test vendor</FullName>
                        </PayeeEntityRef>
                        <RefNumber>1234</RefNumber>
                        <TxnDate>2011-07-04</TxnDate>
                        <IsToBePrinted>false</IsToBePrinted>
                        <ExpenseLineAdd>
                            <Amount>40.00</Amount>
                            <Memo>test memo</Memo>
                            <CustomerRef>
                                <FullName>Michael Baxter</FullName>
                            </CustomerRef>
                        </ExpenseLineAdd>
                    </CheckAdd>
                </CheckAddRq>
            </QBXMLMsgsRq>
        </QBXML> 

Any idea what might cause this?
I am using QB Premier 2009 Desktop

QBWC and QB have been a little flaky lately.  If nothing is wrong with the QBXML above should I reinstall?

Re: API addCheck

You're not embedding the requestID="..." attribute. Embed it in your request and you'll be fine.

<CheckAddRq requestID="' . $requestID . '">

Your qbXML is wrong, this has nothing to do with QuickBooks or the Web Connector being flaky.

Re: API addCheck

When using the API how do I embed requestID?  Do I need to use the "old style" where I use my own schema and not have the API generate it for me?  Is this something new?  I have never had to do anything with requestID when using the API in the past.

This probably does not apply to my problem but I was looking through the code and found a hard coded path to a file:

$contents = file_get_contents('/home/asdg/QuickBooks/QBXML/Schema/Object/Template.php');

Located in QuickBooks/QBXML/Schema/Generator.php line 142.

Last edited by tom (2011-07-05 10:30:11)

Re: API addCheck

Post your code. There are like 4 different APIs you could be talking about here, so you're going to need to be a bit more specific.

Re: API addCheck

Here is what I am using to queue the check add request.

        if (function_exists('date_default_timezone_set'))
        {
            date_default_timezone_set('America/New_York');
        }
        ini_set('display_errors', 1);
        error_reporting(E_ALL);

        require_once 'QuickBooks.php';
        require ('QBdbcon.php');
        $source_type = QuickBooks_API::SOURCE_WEB;
        $dsn = 'mysql://' . $dbuser . ':' . $dbpass . '@localhost/' . $database;
        $source_dsn = 'http://' . $qbuser . ':' . $qbpass . '@localhost/api_server.php';
        $api_options = array();
        $source_options = array();
        $driver_options = array();

        $API = new QuickBooks_API($dsn, $qbuser, $source_type, $source_dsn, $api_options, $source_options, $driver_options);

            $Check = new QuickBooks_Object_Check();

            $Check->setRefNumber(1234);
            $Check->setPayeeEntityFullName('test vendor');
            $Check->setTxnDate(time());
            $Check->setIsToBePrinted(false);
            $ExpenseLine = new QuickBooks_Object_Check_ExpenseLine();
            $ExpenseLine->setMemo('test memo');
            $ExpenseLine->setCustomerFullName('Michael Baxter');
            $ExpenseLine->setAmount(40.0);
            $Check->addExpenseLine($ExpenseLine);
            $API->addCheck($Check);

This is for the web connector. 

        if (function_exists('date_default_timezone_set'))
        {
            date_default_timezone_set('America/New_York');
        }
        require ('QBdbcon.php');
        require_once 'QuickBooks.php';
        $dsn = 'mysql://' . $dbuser . ':' . $dbpass . '@localhost/' . $database;

        // You can ignore these for now...
        $map = array();
        $onerror = array();
        $hooks = array();

        // Logging level
        $log_level = QUICKBOOKS_LOG_DEVELOP;
        //$log_level = QUICKBOOKS_LOG_VERBOSE;
        //$log_level = QUICKBOOKS_LOG_NORMAL;
        //$log_level = QUICKBOOKS_LOG_NONE;
        //require_once 'api_client.php';
        // Create the server instance and handle any requests
        $Server = new QuickBooks_Server_API(
            $dsn,
            $qbuser,
            $map,
            $onerror,
            $hooks,
            $log_level);
        $Server->handle(true, true);

The API is generating the qbxml so how am I supposed to embed something in it?

Last edited by tom (2011-07-06 15:52:56)

Re: API addCheck

Does the API even work with the addCheck method?  I say API since all the examples say API so if there is another name to go by please let me know.  The class instantiated is QuickBooks_API.

Re: API addCheck

I think that's a case of the QuickBooks_API class not supporting that/having a bug. I'll try to look at that soon.

Re: API addCheck

Zithromax Dosage For Std Order Prevacid  order cialis online Generique Levitra 20 10mg 2.5mg Cialis Canadian

Is Amoxicillin Good Zithromax Order Cialis Brausetabletten  cialis without a doctor's prescription Cheapest Tadalafil Fedex Shipping Secure Ordering Levaquin Amex Accepted Website Overseas

Re: API addCheck

Four Corners Pharmacy New Zealand  extra super levitra Achat Cialis Super Active 24h Worldwide isotretinoin by money order in usa price Rx Rx4u Drugs

Is Amoxicillin Good Zithromax Order Cialis Brausetabletten  cialis without a doctor's prescription Cheapest Tadalafil Fedex Shipping Secure Ordering Levaquin Amex Accepted Website Overseas