HI Everyone,
So I’m having issues updating a record using the API, i can authenticate and retrieve a record fine , but editing or adding doesn’t seem to work. Table has one key column PROPERTY_NO and the table name is bin_data_gla. My php code to edit a record is using CURL and is as follows, ( note CURLOPT_URL has been trimmed to allow this post)
CURLOPT_URL => “?action=edit&object=bin_data_gla&PROPERTY_NO=15117”,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => “”,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => “POST”,
CURLOPT_HTTPHEADER => array(
“Content-Type: application/json”,
$xaut
),
));
$response2 = curl_exec($curl2);
$err = curl_error($curl2);
if ($err) {
echo “cURL Error #:” . $err;
} else{
echo “cURL Return :
”;
$jsonObj = json_decode($response2);
$regs = $jsonObj->links;
var_dump($jsonObj);
echo “
”;
print_r($regs);
}
curl_close($curl2);
The response i get is
cURL Return :
NULL
Hi, thanks for your questions / comments.
I already have JWT and authentication working, i just left tat code out as that part is all working and didn’t want extra code confusing the issue.
I have changed the content type to Content-Type: text/html, still no difference.
And the record im editing does exist as i can do an action=view with my separate view code and it returns the data. Im not sure why you say there is no data to edit?
Any other ideas?
Got it to work, for anyone else interested here is my edit code
curl_setopt_array($curl2, array(
CURLOPT_URL => “?action=edit&object=bin_data_gla”,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => “”,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_2_0,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_CUSTOMREQUEST => “POST”,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => “PROPERTY_NO=15125&binserial=55555555555”,
CURLOPT_HTTPHEADER => array(
$xaut
),
));
$response2 = curl_exec($curl2);
$err = curl_error($curl2);
if ($err) {
echo “cURL Error #:” . $err;
} else{
echo “cURL Return :
”;
$jsonObj = json_decode($response2);
$regs = $jsonObj->links;
var_dump($jsonObj);
echo “
”;
print_r($regs);
}