Validate an invoice with api

I want to validate invoice with api

creat invoice work, invoice id = 29

but validate the invoice failed :
http://myurl_dolibar_api/invoices/29/validate

could you help me

//

// Code
//

// Create an invoice
$newFacture = [
“ref” => $facture_ref,
“ref_client” => $facture_lib,
“socid” => $socid,
“contact_id” => $contact_id,
“fk_project” => $project_id,
“type” => “0”, // commande client
“cond_reglement_id” => 6, // 6=‘A la commande’ ; 5=‘60 jours fin de mois’ - cf. http://www.clotilderanno.com/dolibarr/admin/dict.php?id=12
“mode_reglement_id” => 6, // 6='Carte Bancaire
“demand_reason_id” => 8, // 8=‘Bouche à oreille’
“availability_id” => 5, // 5=‘1 mois’ ; 4=‘3 semaines’ -cf. http://localhost/dolibarr/admin/dict.php?id=21
“fk_account” => 1, // 1=‘SAS Clotilde Ranno’
“date” => “2017-07-27”, // ??
“date_commande” => “2017-07-27”, // ??
“date_livraison” => “2017-08-28”, // ??
“lines” => $newCommandeLine,
“note_private” => “order created automatically with API”,
];

		//"user_valid"			=\> 1,
		//"fk_user_valid"		=\> 1,
		
	echo "\n\r--------------------\- facture creation input : \n\r";	
	print_r(json_encode($newFacture));
	echo "\n\r new invoice end. \n\r";		

	$newFactureResult = CallAPI("POST", $token, $dolibarr_endpointUrl."/invoices", json_encode($newFacture ));
	$newFactureResult = json_decode($newFactureResult, true);

	echo "\n\r--------------------\- facture creation answer : \n\r";	
	print_r($newFactureResult);
	echo "\n\r facture order end. \n\r";		
	
	// Validate an invoice 
	$newFactureValider = [
		"idwarehouse"	=\> "0",
		"notrigger"		=\> "0"
	];
			
	$newFactureValiderResult = CallAPI("POST", $token, $dolibarr_endpointUrl."/invoices/".$newFactureResult."/validate", json_encode($newFactureValider));
	$newFactureValiderResult = json_decode($newFactureValiderResult, true);		
	
	echo "\n\r--------------------\- facture creation answer for validation : \n\r";	
	print_r($newFactureValiderResult);
	echo "\n\r  end !!!! \n\r";		

//

// Result
//

--------------------- facture creation answer :
22
facture order end.

--------------------- facture creation answer for validation :
Array
(
[error] => Array
(
[code]
=> 404
[message] => Not Found
)

)

Hum, strange the action “validate” for invoices was missing. I fixed this for version 6.0 (soon available)

1 Like

Thanks

It’s missed paiement method too, it will be fine if you add it in version 6.x too.

cf.
www.dolibarr.org/t/paid-an-invoice-with-api/15867/1

Hi, Also after Validating a Invoice, for creating Recurring Invoices, do we have API ?