Page 1 of 1

RESTful API, problems with addKeyword

PostPosted:Wed Mar 28, 2018 8:59 am
by juanan
Hello,

We are using REST Api on PHP without problems until we want to use the addKeyword property,

This is the code:
Code: Select all
$url = "http://http://192.168.1.199:8080/OpenKM/services/rest/property/addKeyword";
$val = array("nodeId" => "d570e064-aff8-4033-861f-8d2b1a99c7da", "keyword" => "clave");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "USER:PASSWORD");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $val);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "Accept: application/json",
    'Content-Type: application/json'
));

$res = curl_exec($ch);
echo $res;

if (curl_errno($ch)) {
  return curl_error($ch);
} else {
  return $res;
}
curl_close($ch);
after executing this is the error string:

NullPointerException: null

Thank you

Re: RESTful API, problems with addKeyword

PostPosted:Fri Mar 30, 2018 7:18 am
by jllort
The call seems right. Please share with us the catalina.log file ( only the section where is shown the complete stack of the error ).

Why are not using SDK for PHP https://docs.openkm.com/kcenter/view/sdk4php-1.1.2/ ?