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 login
ass "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 !