1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| post = new TStringStream("...");
IdHTTP_recuperation_token->Request->Clear();
IdHTTP_recuperation_token->Request->Accept = "application/xml";
IdHTTP_recuperation_token->Request->ContentType = "application/json";
try{
reponse = IdHTTP_recuperation_token->Post(url,post);
DM_report->OSP_recuperation_token->Close();
DM_report->OSP_recuperation_token->ParamByName("p_xml")->AsString = reponse;
DM_report->OSP_recuperation_token->Execute();
token = DM_report->OSP_recuperation_token->Params->ParamValues["P_TOKEN"];
}
catch (EIdException &e){
MessageDlg(e.Message, mtWarning, TMsgDlgButtons() << mbOK, 0);
}
// Création du document dans la GED
post = new TStringStream("...");
IdHTTP_creation_doc_ged->Request->Clear();
IdHTTP_creation_doc_ged->Request->Accept = "application/xml";
IdHTTP_creation_doc_ged->Request->ContentType = "application/json";
IdHTTP_creation_doc_ged->Request->CustomHeaders->Add("x-access-token: "+token);
try{
reponse = IdHTTP_creation_doc_ged->Post(url,post);
DM_report->OSP_recuperation_gedId->Close();
DM_report->OSP_recuperation_gedId->ParamByName("p_xml")->AsString = reponse;
DM_report->OSP_recuperation_gedId->Execute();
gedId = DM_report->OSP_recuperation_gedId->Params->ParamValues["P_IDGED"];
}
catch (EIdException &e){
MessageDlg(e.Message, mtWarning, TMsgDlgButtons() << mbOK, 0);
}
// Envoi de la facture en PDF (fichier) dans la GED
facture = new TFileStream(ExtractFilePath(Application->ExeName) + "\\"+IntToStr(fac)+".pdf", Sysutils::fmOpenRead);
IdHTTP_envoi_pdf->Request->Clear();
IdHTTP_envoi_pdf->Request->Accept = "application/xml";
IdHTTP_envoi_pdf->Request->ContentType = "application/x-www-form-urlencoded";
IdHTTP_envoi_pdf->Request->CustomHeaders->Add("x-access-token: "+token);
try{
reponse = IdHTTP_envoi_pdf->Put(url,facture);
}
catch (EIdException &e){
MessageDlg(e.Message, mtWarning, TMsgDlgButtons() << mbOK, 0);
}
facture->Free(); |
Partager