user3059034
user3059034

Reputation: 11

quickbooks online api invoice DocNumber

My script for automatically generating invoices using the V2 api has stopped working even though my code is unchanged. The problem seems to be related to my use of the AUTO_GENERATE flag for the DocNumber field. I need QBO to auto-generate a DocNumber and this method was working fine for me up until today. I tried removing DocNumber completely, which created an invoice, however that invoice had no DocNumber id associated with it which I require. Please let me know if there is a workaround of if something was changed on QBO's side which could be fixed.

Also, please don't ask me to just upgrade to the V3 API, eventually I would like to but this is not feasible right now.

MY HTTP request:

POST /qbo30/resource/invoice/v2/<MY_REALM_ID> 
...oauth headers...
<Invoice xmlns="http://www.intuit.com/sb/cdm/v2">
<Header>
    <DocNumber>AUTO_GENERATE</DocNumber>
    <CustomerId>399</CustomerId>
    <SalesTermId>12</SalesTermId>
    <Msg/>
    <Note>Nov 2013</Note>
</Header>
<Line>
    <ItemId>5</ItemId>
    <Desc>Clickthrough Advertising</Desc>
    <Qty>125</Qty>
    <UnitPrice>0.25</UnitPrice>
    <Amount>31.25</Amount>
</Line>
<Line>
    <ItemId>17</ItemId>
    <Desc>Minimum Monthly Charge</Desc>
    <Qty>1</Qty>
    <UnitPrice>68.75</UnitPrice>
    <Amount>68.75</Amount>
</Line>
</Invoice>

QBO's response:

reply: 'HTTP/1.1 400 Bad Request\r\n'
header: Date: Mon, 02 Dec 2013 21:19:39 GMT
header: Server: Apache
header: Content-Length: 283
header: Vary: Accept-Encoding
header: Connection: close
header: Content-Type: application/xml
<FaultInfo xmlns="http://www.intuit.com/sb/cdm/baseexceptionmodel/xsd">
  <Message>You must specify a different number. This number has already been used.</Message>
  <ErrorCode>BAD_REQUEST</ErrorCode>
  <Cause>-13006</Cause>
</FaultInfo>

Upvotes: 0

Views: 1086

Answers (2)

user3059034
user3059034

Reputation: 11

It turns out I had two invoices in our system with the same invoice number. I had to change the number on the offending invoice, then create a new dummy invoice with a higher number which seems to have incremented the auto-increment value appropriately.

Thanks for the comments and the assistance!

Upvotes: 1

Manas Mukherjee
Manas Mukherjee

Reputation: 5340

Just now, I've tried this. It is working fine for me. PFB details. Please check if you are missing something.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Invoice xmlns="http://www.intuit.com/sb/cdm/v2" xmlns:ns2="http://www.intuit.com/sb/cdm/qbopayroll/v1" xmlns:ns3="http://www.intuit.com/sb/cdm/qbo">
    <Header>
        <DocNumber>AUTO_GENERATE</DocNumber>
        <TxnDate>2013-12-02-08:00</TxnDate>
        <CustomerId idDomain="QBO">1</CustomerId>
        <SubTotalAmt>100.00</SubTotalAmt>
        <TotalAmt>100123.00</TotalAmt>
        <ToBePrinted>true</ToBePrinted>
        <ToBeEmailed>false</ToBeEmailed>
        <SalesTermId idDomain="QBO">3</SalesTermId>
        <DueDate>2014-01-01-08:00</DueDate>
        <ShipMethodId idDomain="QBO" />
        <Balance>100321.00</Balance>
        <DiscountTaxable>true</DiscountTaxable>
    </Header>
    <Line>
        <Desc>Test</Desc>
        <Amount>100.00</Amount>
        <Taxable>false</Taxable>
        <ItemId idDomain="QBO">2</ItemId>
    </Line>
</Invoice>

Response

<Invoice xmlns="http://www.intuit.com/sb/cdm/v2" xmlns:qbp="http://www.intuit.com/sb/cdm/qbopayroll/v1" xmlns:qbo="http://www.intuit.com/sb/cdm/qbo">
  <Id idDomain="QBO">9</Id>
  <SyncToken>0</SyncToken>
  <MetaData>
    <CreateTime>2013-12-02T23:17:49-08:00</CreateTime>
    <LastUpdatedTime>2013-12-02T23:17:49-08:00</LastUpdatedTime>
  </MetaData>
  <Header>
    <DocNumber>1003</DocNumber>
    <TxnDate>2013-12-02-08:00</TxnDate>
    <CustomerId idDomain="QBO">1</CustomerId>
    <SubTotalAmt>100.00</SubTotalAmt>
    <TotalAmt>100.00</TotalAmt>
    <ToBePrinted>true</ToBePrinted>
    <ToBeEmailed>false</ToBeEmailed>
    <SalesTermId idDomain="QBO">3</SalesTermId>
    <DueDate>2014-01-01-08:00</DueDate>
    <ShipMethodId idDomain="QBO" />
    <Balance>100.00</Balance>
    <DiscountTaxable>true</DiscountTaxable>
  </Header>
  <Line>
    <Desc>Test</Desc>
    <Amount>100.00</Amount>
    <Taxable>false</Taxable>
    <ItemId idDomain="QBO">2</ItemId>
  </Line>
</Invoice>

It could be a bug or there could be some issues in your QBO account. Please raise a support ticket for this.

Thanks

Upvotes: 0

Related Questions