Question

I'm trying to create a test invoice at quickbooks using quickbooks-ruby gem. Note I have a test account at QB which doesn't have anything: invoice, customer, etc. It's a new account created only for testing purpose. So here is my code:

service = Quickbooks::Service::Invoice.new
service.company_id = current_user.company_id
service.access_token = create_consumer

qb_invoice = Quickbooks::Model::Invoice.new
qb_invoice.customer_id = 123

line_item = Quickbooks::Model::InvoiceLineItem.new
line_item.amount = 100
line_item.sales_item! do |detail|
  detail.unit_price = 100
  detail.quantity = 1
  detail.item_id = 1
end

qb_invoice.line_items << line_item

res = service.create qb_invoice
p res.id #exception!

def create_consumer
  OAuth::AccessToken.new(.....)
end

Request:

   METHOD = post
   RESOURCE = https://qb.sbfinance.intuit.com/v3/company/fdsfdsfdsfds123/invoice

<?xml version="1.0" encoding="utf-8"?>
<Invoice xmlns="http://schema.intuit.com/finance/v3" sparse="false">
  <Line>
    <Amount>100.0</Amount>
    <DetailType>SalesItemLineDetail</DetailType>
    <SalesItemLineDetail>
    <ItemRef>1</ItemRef>
    <UnitPrice>100.0</UnitPrice>
    <RatePercent>0.0</RatePercent>
    <Qty>1.0</Qty>
    </SalesItemLineDetail>
  </Line>
  <CustomerRef>123</CustomerRef>
  <TotalAmt>0.0</TotalAmt>
  <Balance>0.0</Balance>
  <Deposit>0.0</Deposit>
</Invoice>

and response with the error:

RESPONSE CODE = 400

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2014-03-06T19:30:49.168-08:00">
  <Fault type="ValidationFault">
    <Error code="2500" element="">
      <Message>Invalid Reference Id</Message>
      <Detail>Invalid Reference Id : Something you're trying to use has been deleted. Check the fields with accounts, customers, items, vendors or employees.
      </Detail>
    </Error>
  </Fault>
</IntuitResponse>

Could it be because a customer with id = 123 doesn't exist? If not, what's the cause then?

Was it helpful?

Solution

Please check if you have a customer(ID-123) and Item(Id-1) exist in your account.

If not then create these two entries using apiexplorer/code and use the corresponding object IDs.

ApiExplorer - https://developer.intuit.com/apiexplorer?apiname=V3QBO

EntityRef - https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/030_entity_services_reference

ApiExplorer -

enter image description here

Ref - https://developer.intuit.com/docs/0025_quickbooksapi/0010_getting_started/0015_firstrequest

Thanks

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top