code error 4 - XMLString should be a part of the request

code error 4 - XMLString should be a part of the request

Hello,

Try to add an invoice from php using curl but I get " XMLString should be a part of the request" error.
My code is simple

  1. $query = urlencode('authtoken='.AUTHTOKEN.'&apikey='.APIKey.'&SCOPE'.scope.'&XMLString='.$xml);
  2. $x = curl_init("https://invoice.zoho.com/api/invoices/create");
  3. curl_setopt($x, CURLOPT_HEADER, 0);
  4. curl_setopt($x, CURLOPT_POST, 1);
  5. curl_setopt($x, CURLOPT_POSTFIELDS, $query);
  6. curl_setopt($x, CURLOPT_FOLLOWLOCATION, 0);
  7. curl_setopt($x, CURLOPT_RETURNTRANSFER, 1);
  8. $data = curl_exec($x);
  9. curl_close($x);
  10. echo $data;
The xml sent is a valid one:

  1. <Invoice>
  2.       <CustomerID>20</CustomerID>   
  3.       <InvoiceDate>2011-09-27</InvoiceDate>
  4.       <InvoiceNumber>TUBI20</InvoiceNumber>   
  5.       <PONumber>20</PONumber>
  6.       <ExchangeRate>1</ExchangeRate>  
  7.       <LFName>Flat fee daily</LFName>
  8.       <PaymentGateways>
  9.             <PayPal>0</PayPal>   
  10.       <Authorize.Net>false</Authorize.Net>    
  11.       <GoogleCheckout>false</GoogleCheckout>    
  12.       </PaymentGateways>
  13.       <InvoiceItems>
  14.             <InvoiceItem>
  15. <ItemName>01019112000BR </ItemName>   
  16. <ItemDescription>F.40 NON KAT LOUD EXHAUST + BORDINO </ItemDescription>
  17. <Price>4051.14</Price>
  18. <Quantity>1</Quantity>
  19.       </InvoiceItem>     
  20.       </InvoiceItems>
  21.       <Comments>
  22.             <Comment><Description></Description></Comment>
  23.       </Comments>
  24.       <Notes></Notes>
  25.       <Terms></Terms>
  26. </Invoice>

Can anyone help me please?
Thank you!