EcritureService :: InsertPiece​

The POST method, is used to retrieve data.

The list of necessary parameters for sending a query:

  • Ecriture ecriture,
  • bool useSageProcess = true

Returns data as JSON, for use in PHP, you need to convert JSON in StdClass PHP (PHP function: json_decode ()).

Input parameters:

{
  "ecriture": {
    "Id": 0,
    "CodeJournal": "ACH",
    "NumeroPiece": "",
    "DateEcriture": "/Date(1426201200000+0100)/",
    "DateSaisie": "/Date(1426201200000+0100)/",
    "DateEcheance": "/Date(1426201200000+0100)/",
    "NumeroFacture": "",
    "Reference": "REF 123456",
    "Intitule": "Ecritures de test",
    "CompteGeneral": "asdfadsf",
    "CompteGeneralContrepartie": "adsfsdaf",
    "NumeroTiers": "ECLAT",
    "NumeroTiersContrepartie": "",
    "Montant": 256.54,
    "Sens": 0,
    "Parite": 0,
    "MontantDevise": 0,
    "IdDevise": 0,
    "CodeTaxe": "",
    "IdReglement": 4,
    "EstLettree": false,
    "Lettre": ""
  }
}

Example:

require (__DIR__ . '/service/Ecriture.php');

use services\Ecriture;
use services\WebServices100;

$url = 'http://<Your ip>:<Your Port>/WebServices100/<Your environment>/EcritureService/rest/InsertPiece';

// add parameters
$ecriture = new Ecriture();

$ecriture->setId();
$ecriture->setCodeJournal("ACH");
$ecriture->setNumeroPiece();
$ecriture->setDateEcriture("/Date(1426201200000+0100)/");
$ecriture->setDateSaisie("/Date(1426201200000+0100)/");
$ecriture->setDateEcheance("/Date(1426201200000+0100)/");
$ecriture->setNumeroFacture();
$ecriture->setReference("REF 123456");
$ecriture->setIntitule("Ecritures de test");
$ecriture->setCompteGeneral("asdfadsf");
$ecriture->setCompteGeneralContrepartie("adsfsdaf");
$ecriture->setNumeroTiers("ECLAT");
$ecriture->setNumeroTiersContrepartie();
$ecriture->setMontant(256.54);
$ecriture->setSens();
$ecriture->setParite();
$ecriture->setMontantDevise();
$ecriture->setIdDevise();
$ecriture->setCodeTaxe();
$ecriture->setIdReglement(4);
$ecriture->setEstLettree();
$ecriture->setLettre();
$ecriture->InfosLibres();


$data = new stdClass();
$data->ecriture = new stdClass();
$data->ecriture = $ecriture->getResponse();

$json_data = json_encode($data, JSON_UNESCAPED_SLASHES);

// Send requests to receive data
$result = WebServices100::getData($url, $json_data);

$response = json_decode($result);

Result:

Array of Ecritures