SEARCH API : find by ancestor

cancel
Showing results for 
Search instead for 
Did you mean: 
JC83
Active Member II

SEARCH API : find by ancestor

Jump to solution

Hi,

I'm facing an issue with APi REST
I'm just trying to perform a simple search request :

this works perfectly though curl under bash

curl -s -u loginSmiley Tongueass "http://localhost:8080/alfresco/api/-default-/public/search/versions/1/search" --data '{"query":{"query":"ANCESTOR:\"workspace://SpacesStore/1928ee33-6f85-4543-bd67-3b8b29641946\""}}'

But there is no way to make it works under php

$url = "$SURLBASE/search";

$myquery = array("query" => 'ANCESTOR:"workspace://SpacesStore/'.$parentfolder.'"'); // AND irfm:status:Approved");
$processBody = array(
"query" => $myquery,
"paging" => array(
"maxItems" => "500000"
)
);
$processBody = array("query" => $myquery);
$processBodyjson=json_encode($processBody,JSON_UNESCAPED_SLASHES );
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL, $url);
//to avoid curl_exec to perform as "echo"
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json;charset=UTF-8"));
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_POSTFIELDS, $processBodyjson );
$json = curl_exec($ch);
$array = json_decode($json, 1);
curl_close($ch);
return($array);

The answer is :

Array
(
[error] => Array
(
[errorKey] => framework.exception.NotFound
[statusCode] => 404
[briefSummary] => 07238988 {0} introuvable
[stackTrace] => Pour des raisons de sécurité, le traçage de la pile n'est plus affiché, mais la propriété est conservée dans les versions précédente.
[descriptionURL] => https://api-explorer.alfresco.com
)

)

what am i doing wrong ?
thank you !

1 Solution

Accepted Solutions
JC83
Active Member II
3 Replies
angelborroy
Alfresco Employee

Re: SEARCH API : find by ancestor

Jump to solution

Based on the error message, it suggests that the Alfresco server is not able to locate the resource you're requesting. This typically happens when the request URL or body is incorrect or not properly formatted. Verify that your php code is invoking to the same URL you're testing with curl.

Hyland Developer Evangelist
JC83
Active Member II

Re: SEARCH API : find by ancestor

Jump to solution

Thanks for the answer

URL in PHP code is a copy/paste one from the bash command line ..

I guess this is a matter of syntax with the slashs .. but .. Is there a way to have a more detailed error (with the received data for example) ??

 

thanks again

JC83
Active Member II