Daniel Vukasovich
Daniel Vukasovich

Reputation: 1742

can't create an invoice using JSON API (but XML works OK)

I can create a new invoice using XML V3 QBO API:

<Invoice xmlns="http://schema.intuit.com/finance/v3">
       <Line>
            <Description>Installation labor</Description>
            <Amount>420.00</Amount>
            <DetailType>SalesItemLineDetail</DetailType>
            <SalesItemLineDetail>
                <ItemRef>1</ItemRef>
            </SalesItemLineDetail>
        </Line>
      <CustomerRef>58</CustomerRef>
</Invoice>

But I can't perform the same opeartion using JSON API. The JSON payload is:

{
  "Line": [
    {
      "Amount": 100.00,
      "DetailType": "SalesItemLineDetail",
      "SalesItemLineDetail": {
        "ItemRef": {
          "value": "1",
          "name": "Services"
        }
      }
    }
  ],
  "CustomerRef": {
    "value": "58"
  }
}

The JSON example returns the following error:

{"Fault":{"Error":[{"Message":"An application error has occurred while processing your request","Detail":"System Failure Error: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.","code":"10000"}],"type":"SystemFault"},"time":"2015-11-26T06:09:56.540-08:00"}

I'm performing both operations using Intuit's developer console.

Thanks

Upvotes: 0

Views: 534

Answers (2)

nimisha shrivastava
nimisha shrivastava

Reputation: 2367

Please change the content-type to JSON on API explorer when you test the Invoice json request

Upvotes: 1

Sushanta Babason
Sushanta Babason

Reputation: 31

I'm not familiar with Intuit's developer console, but in your xml you have an object called "Invoice", which isn't specifically present int the JSON object, perhaps: {"Invoice": {"Line":{...}}}

Upvotes: 2

Related Questions