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>
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!