11-15-2013 05:25 AM
Hi,
I'm using the PHP Automation Client to execute a simple query and I have an error on it, and I don't know how can I resolve it. Obviously I changed the url of Nuxeo, and the correct username and password when I get a session.
Here the code:
$client = new PhpAutomationClient('http://localhost:8080/nuxeo/site/automation');
$session = $client->getSession('Administrator','Administrator');
$answer = $session->newRequest("Document.Query")->set('params', 'query', "SELECT * FROM Document" )->sendRequest();
$documentsArray = $answer->getDocumentList();
And here the error:
Fatal error: Call to a member function getDocumentList() on a non-object in C:\wamp\www\utils\test.php on line 118
But, If before getDocumentList(), I do a var_dump($answer), I see the JSON document listing all documents that means that I received the server answer.
Can someone explain me what's the problem? Thanks in advance!
11-19-2013 11:38 AM
Ok, you need to modify the file NuxeoAutomationUtilities.php:
a) this is optional
public function NuxeoRequest($url, $headers = "Content-Type:application/json+nxrequest", $requestId) {
$this->url = $url . "/" . $requestId;
$this->headers = $headers;
$this->finalRequest = array(""=>""); // it is treated as array in "set" method
$this->method = 'POST';
$this->iterationNumber = 0;
$this->HEADER_NX_SCHEMAS = 'X-NXDocumentProperties:';
$this->blobList = null;
$this->X_NXVoidOperation = 'X-NXVoidOperation: true';
}
b) this is crucial
public function setSchema($schema = '*') {
// $this->headers = array($this->headers, $this->HEADER_NX_SCHEMAS . $schema); // it is the problem.
$this->headers = $this->headers."\r\n". $this->HEADER_NX_SCHEMAS . $schema;
return $this;
}
Best regards
11-15-2013 09:48 AM
Hi,
11-18-2013 01:23 AM
Hi Vladimir,
11-18-2013 08:03 AM
Hi,
You should look:
a) what sendRequest method is doing,
b) what constructor NuxeoDocuments is doing.
ad. a)
If json_decode($answer, true) returns null then a result from sendRequest is a pure response from a server.
ad. b)
json_decode($answer, true) returns not null then sendRequest returns the result from calling NuxeoDocuments(json_decode($answer, true)). NuxeoDocuments checks if its parameter contains elements 'entries' or 'uid' then it returns object. Otherwise it returns the parameter or an error 'file not found'.
You should check what case is in your example.
Best regards
11-18-2013 09:06 AM
Hi,
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.