Update signature date in ThirdParty > Payments via the REST API

Hello,

I would like to update signature date in ThirdParty > Payments via the REST API. To do that I tried to use following method: Module Web Services API REST (developer) - Dolibarr ERP CRM Wiki

So I built following code (in PHP):

//set variables variables
$apikey= "XxXxX";
$apiurl= "https://[...]/api/index.php/";

//retrieve variables values (GET)
$socid=$_GET["socid"];
$rib=$_GET["rib"];

//Update signature date for SEPA authorization
$method = "PUT";
$url= $apiurl . "thirdparties/" . $socid . "/bankaccounts/" . $rib;
$data= json_encode(["date_rum" => date()]);
echo (callAPI($method, $apikey, $url, $data));

With the “callAPI” function suggested in the Wiki:

// Function to call a REST API
function callAPI($method, $apikey, $url, $data = false)
{
	$curl = curl_init();
	$httpheader = ['DOLAPIKEY: '.$apikey];

	switch ($method)
	{
		case "POST":
			curl_setopt($curl, CURLOPT_POST, 1);
			$httpheader[] = "Content-Type:application/json";

			if ($data)
				curl_setopt($curl, CURLOPT_POSTFIELDS, $data);

			break;
		case "PUT":

		curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
			$httpheader[] = "Content-Type:application/json";

			if ($data)
				curl_setopt($curl, CURLOPT_POSTFIELDS, $data);

			break;
		default:
			if ($data)
				$url = sprintf("%s?%s", $url, http_build_query($data));
	}

	curl_setopt($curl, CURLOPT_URL, $url);
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($curl, CURLOPT_HTTPHEADER, $httpheader);

	$result = curl_exec($curl);

	curl_close($curl);

	return $result;
}

Unfortunately, when I run this code, I get following error message:

It seems there is a bug in the generated SQL (as you can see, where clause is ‘WHERE rowid=25 WHERE fk_soc=33’ instead of ‘WHERE rowid = 25 AND fk_soc = 33’).

(context : Dolibarr 14.0.5, PHP 7.4)

May I ask your help to update this date in PHP based on the API?

Thank you by advance,
Best regards,

Just in case, I created an entry in GitHub regarding this SQL error:

1 Like