Bills and Stock

The API documentation for creating bills seems to be incomplete. There is
no explanation of how to add a stock item if the “Purchase of Stock”
category is selected when creating a bill. Does anyone know what the field
names are for the “Stock item” and “Quantity” fields?

Furthermore, there is no “Purchase of Stock” category in the API category
listing. I find that if I use the “Stock” category then I get the error
message “you must specify a stock item to use this category”, so it
certainly looks like the API is expecting a stock item for a bill with this
category, but giving a stock id in a field with the name “stock_item” (as
we do for an invoice) does not make the error message go away.

Below is the relevant code for the method that I have written in a php
class. I have highlighted relevant fields in red.

$curl=curl_init($this->FreeAgentEndpoint."/v2/bills");
$post=array();
$post[“bill”]=array();
$post[“bill”][“contact”]=$contact;
$post[“bill”][“comments”]=$comments;
$post[“bill”][“reference”]=$reference;
$post[“bill”][“dated_on”]=$billDate;
$post[“bill”][“due_on”]=$dueDate;
$post[“bill”][“category”]=$this->getCategory(“Stock”);
$post[“bill”][“total_value”]=$value;
$post[“bill”][“sales_tax_rate”]=$taxRate;
$post[“bill”][“stock_item”]=$stock;
$post[“bill”][“quantity”]=$quantity;
$post=json_encode($post);
curl_setopt($curl,CURLOPT_POST,true);
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($curl, CURLOPT_SSLVERSION, 6);
curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,2);
curl_setopt($curl,CURLOPT_HEADER,false);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl,CURLOPT_POSTFIELDS,$post);
curl_setopt($curl,CURLOPT_HTTPHEADER,array(“Authorization: Bearer
{$this->bearer}”,“Accept: application/json”,“Content-Type:
application/json”));
curl_setopt($curl,CURLOPT_USERAGENT,“Revision Tools {$this->version}”);
//Execute the cURL call.
$response=curl_exec($curl);