Questo metodo deve essere utilizzato dall’OE per effettuare l’invio di una fattura nel formato XML e già firmata digitalmente secondo norme AGID, ovvero con estension .p7m e formato CAdES-BES (CMS Advanced Electronic Signatures).
curl -X POST https://demows.fatturazioneelettronica.aruba.it/services/invoice/uploadSigned \
-H 'Accept: application/json' \
-H 'Content-Type: application/json;charset=UTF-8' \
-H 'Authorization: Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE=' \
-d '{
"dataFile" : "dGVzdA=="
}'
var
rest: TChilkatRest;
success: Integer;
bTls: Integer;
port: Integer;
bAutoReconnect: Integer;
json: TChilkatJsonObject;
sbRequestBody: TChilkatStringBuilder;
sbResponseBody: TChilkatStringBuilder;
respStatusCode: Integer;
jsonResponse: TChilkatJsonObject;
errorCode: WideString;
errorDescription: WideString;
uploadFileName: WideString;
begin
rest := TChilkatRest.Create(Self);
// URL: https://demows.fatturazioneelettronica.aruba.it/services/invoice/uploadSigned
bTls := 1;
port := 443;
bAutoReconnect := 1;
success := rest.Connect('demows.fatturazioneelettronica.aruba.it',port,bTls,bAutoReconnect);
if (success <> 1) then
begin
Memo1.Lines.Add('ConnectFailReason: ' + IntToStr(rest.ConnectFailReason));
Memo1.Lines.Add(rest.LastErrorText);
Exit;
end;
// See the Online Tool for Generating JSON Creation Code
json := TChilkatJsonObject.Create(Self);
json.UpdateString('dataFile','dGVzdA==');
rest.AddHeader('Content-Type','application/json;charset=UTF-8');
rest.AddHeader('Authorization','Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE=');
rest.AddHeader('Accept','application/json');
sbRequestBody := TChilkatStringBuilder.Create(Self);
json.EmitSb(sbRequestBody.ControlInterface);
sbResponseBody := TChilkatStringBuilder.Create(Self);
success := rest.FullRequestSb('POST','/services/invoice/uploadSigned',sbRequestBody.ControlInterface,sbResponseBody.ControlInterface);
if (success <> 1) then
begin
Memo1.Lines.Add(rest.LastErrorText);
Exit;
end;
respStatusCode := rest.ResponseStatusCode;
if (respStatusCode >= 400) then
begin
Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
Memo1.Lines.Add('Response Header:');
Memo1.Lines.Add(rest.ResponseHeader);
Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(sbResponseBody.GetAsString());
Exit;
end;
jsonResponse := TChilkatJsonObject.Create(Self);
jsonResponse.LoadSb(sbResponseBody.ControlInterface);
// See the Online Tool for Generating JSON Parse Code
errorCode := jsonResponse.StringOf('errorCode');
errorDescription := jsonResponse.StringOf('errorDescription');
uploadFileName := jsonResponse.StringOf('uploadFileName');
{
"errorCode": "",
"errorDescription": "",
"uploadFileName": "IT00499202641_kwefc.xml.p7m"
}