|
Hi
I'm trying to post a request to saasu's REST API via Zend_Rest_Client, and i am completely stuck. isSeccuess fails and gives me the error: "An error occurred while parsing EntityName. Line 1, position 22." On asking Saasu, they have requested the actual XML posted. using $actual_xml = $saasu->getHttpClient()->getLastRequest(); i have sent them "POST /webservices/rest/r1/tasks?wsaccesskey=super-secret-123&FileUid=shhh HTTP/1.1 Host: secure.saasu.com Connection: close Accept-encoding: gzip, deflate User-Agent: Zend_Http_Client Content-Type: application/x-www-form-urlencoded Content-Length: 136 method=insertInvoice&lastUpdatedUid=0&transactionType=S&date=2010-03-10&summary=a+test+order&reference=x11-wills-rubbish&layout=S&rest=1" to which they say "that isn't xml" whats the xml fragment. Can somebody tell me how i get the xml fragment? Am i doing the post correctly? does the warning at the bottom of the manual for this about "Strictness of Zend_Rest_Client" come into play, and if so - how do i tell that is whats going wrong. here is my code: $saasu = new Zend_Rest_Client('https://secure.saasu.com/webservices/rest/r1/tasks?wsaccesskey=super-secret-123&FileUid=shh'); $saasu->insertInvoice(); $saasu->lastUpdatedUid(0); $saasu->transactionType('S'); $saasu->date('2010-03-10'); $saasu->summary('a test order'); $saasu->reference('x11-wills-rubbish'); $saasu->layout('S'); $response = $saasu->Post(); $this->view->response = $response; Thanks very much for any help. Last hope. Will |
|
I suppose one issue is that im not posting xml at all, Im posting querystring style data. I think I thought zend_rest_client would format that appropriatly for me into xml. whoops.
can sombody please tell me how to post an xml request to the api? And does ZF have a handy component to help me build the xml? Thanks very much for any help. will. ps // from saasu's documentation i should be posting something alongs the lines of: <?xml version=”1.0″ encoding=”utf-8″?> <tasks> <updateContact> <contact uid=”23985″ lastUpdatedUid=”AD3872E=”> <salutation>Mrs.</salutation> <givenName>Mary</givenName> <familyName>Smith</familyName> <organisationName>ACME Pty Ltd</organisationName> <organisataionAbn>11 111 111 111</organisationAbn> <contactID>223</contactID> <organisationWebsite>www.acme.com</organisationWebsite> <mobilePhone>0666 666 666</mobilePhone> <homePhone> 02 8888 8888</homePhone> <tags>Prospect, IT</tags> <postalAddress> <street>11/111 ABC Av</street> <city>Sydney</city> <state>NSW</state> </postalAddress> </otherAddress> <isActive>true</isActive> </contact> </updateContact> <insertInvoice emailToContact=”false”> <invoice uid=”0″> <transactionType>S</transactionType> <date>2005-09-30</date> <contactUid>23986</contactUid> <tags>Online Sales, XYZ</tags> <summary>Test POST sale</summary> <notes>From REST</notes> <requiresFollowUp>false</requiresFollowUp> <dueOrExpiryDate>2005-12-01</dueOrExpiryDate> <layout>S</layout> <status>I</status> <invoiceNumber><Auto Number></invoiceNumber> <purchaseOrderNumber>PO222</purchaseOrderNumber> <invoiceItems> <serviceInvoiceItem> <description>Design & Development of REST WS</description> <accountUid>24502</accountUid> <taxCode>G1</taxCode> <totalAmountInclTax>2132.51</totalAmountInclTax> </serviceInvoiceItem> <serviceInvoiceItem> <description>Subscription to XYZ</description> <accountUid>24504</accountUid> <taxCode>G1</taxCode> <totalAmountInclTax>11.22</totalAmountInclTax> </serviceInvoiceItem> </invoiceItems> <quickPayment> <datePaid>2005-09-30</datePaid> <dateCleared />0001-01-01</dateCleared> <bankedToAccountUid>24509</bankedToAccountUid> <amount>100</amount> <reference>CASH</reference> <summary>Quick payment from Westpac.</summary> </quickPayment> <isSent>false</isSent> </invoice> </insertInvoice> <insertInvoice emailToContact=”true”> <invoice uid=”0″> <transactionType>S</transactionType> <date>2005-10-06</date> <contactUid>23987</contactUid> <tags>Online Sales, ABC123</tags> <summary>Test Insert Item Sale</summary> <notes>From REST</notes> <requiresFollowUp>false</requiresFollowUp> <dueOrExpiryDate>2005-11-06</dueOrExpiryDate> <layout>I</layout> <status>I</status> <invoiceNumber><Auto Number></invoiceNumber> <purchaseOrderNumber>PO333</purchaseOrderNumber> <invoiceItems> <itemInvoiceItem> <quantity>2</quantity> <inventoryItemUid>4822</inventoryItemUid> <description>Seagate HDD – 300G</description> <taxCode>G1</taxCode> <unitPriceInclTax>120.75</unitPriceInclTax> </itemInvoiceItem> <itemInvoiceItem> <quantity>5.125</quantity> <inventoryItemUid>4821</inventoryItemUid> <description>Cat 5 Cable (in meter)</description> <taxCode>G1</taxCode> <unitPriceInclTax>2.555</unitPriceInclTax> </itemInvoiceItem> </invoiceItems> <quickPayment> <datePaid>0001-01-01</datePaid> <dateCleared>0001-01-01</dateCleared> <bankedToAccountUid>0</bankedToAccountUid> <amount>0</amount> </quickPayment> <isSent>false</isSent> </invoice> <createAsAdjustmentNote>false</createAsAdjustmentNote> <emailMessage> <from>test@acme.com.au</from> <to>smith@acme.com.au</to> <subject>Invoice</subject> <body>Thanks for shopping with us. Attached is a PDF invoice for your record.</body> </emailMessage> </insertInvoice> </tasks> |
|
Hi Will. Did you work out how to post the XML for insert/update operations? I am working on similar functionality.
Thanks. |
|
Use Zend_Http_Client and call setRawData passing in an xml string. You can use DOMDocument or SimpleXML to create the string. - pw
On Sun, Jul 11, 2010 at 1:05 AM, rooboy <[hidden email]> wrote:
|
|
I had the same problem and in my case the culprit was the '<Auto Number>' element within the Invoice XML. This is quoted exactly like this in the Saasu API, however is obviously not valid XML and Saasu quite rightly refuses it. I simply removed the tag, i.e. am not creating an invoice number. An alternative would be to define that number manually.
If anyone knows how to send the 'Auto Number' parameter correctly in XML, let me know. |
| Powered by Nabble | Edit this page |
