使用v3-php-sdk创建Category类型Item时触发6000业务验证错误
I've run into this exact issue before with the QuickBooks Online v3 PHP SDK—category-type items have stricter implicit validation rules than regular items, even if the docs don't always spell them out clearly. Let's break down what's going wrong and how to fix it.
The Root Cause
Your current array only includes Name, FullyQualifiedName, and Type, but the QBO API requires explicit values for certain boolean fields when creating category items. The generated IPPItem object shows Active and SubItem as empty (not set to true or false), which triggers the 6000 business validation error. QBO doesn't accept null/empty values for these fields for category-type items.
Step-by-Step Fix
Update your item array to include the required boolean fields with explicit values:
$arrayItem = [ 'Name' => 'Item', 'FullyQualifiedName' => 'Item', 'Type' => 'Category', 'Active' => true, // Required explicit boolean 'SubItem' => false // Required explicit boolean (set to true if this is a sub-category) ];
Why This Works
Active: QBO expects all items (including categories) to have a clear active status. Setting this totruealigns with the default behavior for new items.SubItem: Since this is a top-level category (no parent), we explicitly set this tofalse. If you were creating a sub-category, you'd set this totrueand add aParentRefwith the parent category's ID.
Additional Checks
If you still get the error after adding these fields:
- Double-check that
FullyQualifiedNameexactly matchesNamefor top-level categories (this is required to avoid path conflicts). - Ensure there are no existing categories with the same
NameorFullyQualifiedNamein your QBO company (duplicates will also trigger validation errors).
Once you update the array with these values, calling Item::create($arrayItem) should successfully create the category item without the 6000 error.
内容的提问来源于stack exchange,提问作者Aljay

