Creating a Purchase Order with multiple line items using the Zoho API (via XML)

Creating a Purchase Order with multiple line items using the Zoho API (via XML)

I am trying to create a purchase order in Zoho using a call to the Zoho API and am getting an error, even though I'm passing all required fields and matching the format to what I get when I export a similar PO.

I'm trying to create a new purchase order using this URL:

https://crm.zoho.com/crm/private/xml/PurchaseOrders/insertRecords?

This is followed with the following post content:

scope=crmapi&authtoken=xxxxxxxxxx&newFormat=1&xmlData=<PurchaseOrders><row no="1"><FL val="Subject"><![CDATA[PO for Quote # 1615620000000453116 / Vendor # 1615620000000099217]]></FL><FL val="Vendor Name"><![CDATA[Teledyne Isco]]></FL><FL val="VENDORID">1615620000000099217</FL><FL val="Product Details"><product no="1"><FL val="Product Name"><![CDATA[806015320 - CLNR PWR HOUSE  KB (Teledyne)]]></FL><FL val="Product Id">1615620000000327252</FL><FL val="Quantity">2</FL><FL val="Unit Price">23.81</FL><FL val="List Price">23.81</FL></product><product no="2"><FL val="Product Name"><![CDATA[371280630 - RES 806   1/4W  1% (Teledyne)]]></FL><FL val="Product Id">1615620000000293671</FL><FL val="Quantity">5</FL><FL val="Unit Price">0.3</FL><FL val="List Price">150</FL></product></FL></row></PurchaseOrders>

Which represents the following XML (Formatted for easier reading):

<PurchaseOrders>
  <row no="1">
    <FL val="Subject"><![CDATA[PO for Quote # 1615620000000453116 / Vendor # 1615620000000099217]]></FL>
    <FL val="Vendor Name"><![CDATA[Teledyne Isco]]></FL>
    <FL val="VENDORID">1615620000000099217</FL>
    <FL val="Product Details">
      <product no="1">
        <FL val="Product Name"><![CDATA[806015320 - CLNR PWR HOUSE  KB (Teledyne)]]></FL>
        <FL val="Product Id">1615620000000327252</FL>
        <FL val="Quantity">2</FL>
        <FL val="Unit Price">23.81</FL>
        <FL val="List Price">23.81</FL>
      </product>
      <product no="2">
        <FL val="Product Name"><![CDATA[371280630 - RES 806   1/4W  1% (Teledyne)]]></FL>
        <FL val="Product Id">1615620000000293671</FL>
        <FL val="Quantity">5</FL>
        <FL val="Unit Price">0.3</FL>
        <FL val="List Price">150</FL>
      </product>
    </FL>
  </row>
</PurchaseOrders>


What this should do is create a purchase order with minimal information and two products. However, I'm getting the following returned error:

<?xml version="1.0" encoding="UTF-8" ?>
<response uri="/crm/private/xml/PurchaseOrders/insertRecords"><error><code>4600</code><message>Unable to process your request. Please verify if the name and value is appropriate for the "xmlData" parameter.</message></error></response>

To check the format of my xmlData parameter, I used the following API request to EXPORT similar data:

URL:

https://crm.zoho.com/crm/private/xml/PurchaseOrders/getRecordById?

Posted data: 

scope=crmapi&authtoken= xxxxxxxxxx &id=1615620000000330021

Response:

<response uri="/crm/private/xml/PurchaseOrders/getRecordById">
  <result>
    <PurchaseOrders>
      <row no="1">
        <FL val="PURCHASEORDERID">1615620000000330021</FL>
        <FL val="Subject"><![CDATA[2015 Annual Calibration Date]]></FL>
        <FL val="VENDORID">1615620000000099217</FL>
        <FL val="Vendor Name"><![CDATA[Teledyne Isco]]></FL>
        <FL val="CONTACTID">1615620000000104126</FL>
        <FL val="Contact Name"><![CDATA[Ernest Booth]]></FL>
        <FL val="PO Date"><![CDATA[2015-09-03]]></FL>
        <FL val="Carrier"><![CDATA[FedEX]]></FL>
        <FL val="Status"><![CDATA[Created]]></FL>
        <FL val="SMOWNERID">1615620000000085003</FL>
        <FL val="Purchase Order Owner"><![CDATA[Gripp System]]></FL>
        <FL val="SMCREATORID">1615620000000085003</FL>
        <FL val="Created By"><![CDATA[Gripp System]]></FL>
        <FL val="MODIFIEDBY">1615620000000085003</FL>
        <FL val="Modified By"><![CDATA[Gripp System]]></FL>
        <FL val="Created Time"><![CDATA[2015-09-03 14:03:43]]></FL>
        <FL val="Modified Time"><![CDATA[2015-09-03 14:03:43]]></FL>
        <FL val="Sub Total"><![CDATA[247.15]]></FL>
        <FL val="Tax"><![CDATA[0]]></FL>
        <FL val="Adjustment"><![CDATA[0]]></FL>
        <FL val="Grand Total"><![CDATA[247.15]]></FL>
        <FL val="Billing State"><![CDATA[Indiana]]></FL>
        <FL val="Billing Country"><![CDATA[United States]]></FL>
        <FL val="Product Details">
          <product no="1">
            <FL val="Product Id">1615620000000327244</FL>
            <FL val="Product Name"><![CDATA[805001507 - BAG #0 PAD 6 X 10 (Teledyne)]]></FL>
            <FL val="Unit Price">3.4</FL>
            <FL val="Quantity">3.0</FL>
            <FL val="Quantity in Stock">-3.0</FL>
            <FL val="Total">10.2</FL>
            <FL val="Discount">0.0</FL>
            <FL val="Total After Discount">10.2</FL>
            <FL val="List Price">3.4</FL>
            <FL val="Net Total">10.2</FL>
            <FL val="Tax">0.0</FL>
            <FL val="Product Description"><![CDATA[BAG #0 PAD 6 X 10]]></FL>
          </product>
          <product no="2">
            <FL val="Product Id">1615620000000327255</FL>
            <FL val="Product Name"><![CDATA[806017500 - TAPE DFTG 3/4X60YD (Teledyne)]]></FL>
            <FL val="Unit Price">18.95</FL>
            <FL val="Quantity">5.0</FL>
            <FL val="Quantity in Stock">-5.0</FL>
            <FL val="Total">94.75</FL>
            <FL val="Discount">0.0</FL>
            <FL val="Total After Discount">94.75</FL>
            <FL val="List Price">18.95</FL>
            <FL val="Net Total">94.75</FL>
            <FL val="Tax">0.0</FL>
            <FL val="Product Description"><![CDATA[TAPE DFTG 3/4X60YD]]></FL>
          </product>
          <product no="3">
            <FL val="Product Id">1615620000000327260</FL>
            <FL val="Product Name"><![CDATA[810590001 - MSK SOURCE SCREEN (Teledyne)]]></FL>
            <FL val="Unit Price">14.22</FL>
            <FL val="Quantity">10.0</FL>
            <FL val="Quantity in Stock">-10.0</FL>
            <FL val="Total">142.2</FL>
            <FL val="Discount">0.0</FL>
            <FL val="Total After Discount">142.2</FL>
            <FL val="List Price">14.22</FL>
            <FL val="Net Total">142.2</FL>
            <FL val="Tax">0.0</FL>
            <FL val="Product Description"><![CDATA[MSK SOURCE SCREEN]]></FL>
          </product>
        </FL>
        <FL val="Discount"><![CDATA[0]]></FL>
      </row>
    </PurchaseOrders>
  </result>
</response>

As you can see, other than the "response" and "result" tags, which I wouldn't expect to be in the "insert" API post, they are the same, except my post has fewer fields (but it contains all the required fields for a PO listed  here)

In the documentation they don't clearly indicate that you can post multiple products (in the product details node) but when you look at the export, it looks like you should be able to. I've also tried this without the extra nodes (and just posting one product) with results not even this "close" to what I need.