03-01-2019, 09:48 PM
(This post was last modified: 03-01-2019, 09:53 PM by staff@ergosoft.it.)
Hi,
I have this function
function TFDMFE.EncodeFile(const FileName: string): AnsiString;
var
stream: TMemoryStream;
begin
stream := TMemoryStream.Create;
try
stream.LoadFromFile(filename);
result := EncodeBase64(stream.Memory, stream.Size);
finally
FreeAndNil(stream);
end;
end;
procedure TFDMFE.InviaFE(Autorizzazione, PercorsoFileXML, Credenziali, Dominio : string);
var
lHTTP: TIdHTTP;
lParamList: TStringList;
Comando, RisultatoPost : string;
begin
//************ COMANDO HTTP ********
Comando := 'https://ws.fatturazioneelettronica.aruba.it/services/invoice/upload';
//**********************************
lParamList := TStringList.Create;
Credenziali := '""';
Dominio := '""';
try
lParamList.Add('"dataFile":"'+EncodeFile(PercorsoFileXML)+'"');
lParamList.Add('"credential":'+Credenziali); // vuoti
lParamList.Add('"domain":'+Dominio); // vuoti
lHTTP := TIdHTTP.Create;
try
lHTTP.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(lHTTP);
lHTTP.HandleRedirects := True;
lHTTP.Request.CustomHeaders.FoldLines := False;
lHTTP.Request.Accept := 'application/json';
lHTTP.Request.CustomHeaders.Add('Authorization:Bearer ' + Autorizzazione);
lHTTP.Request.ContentType := 'application/json';
lHTTP.Request.CharSet := 'UTF-8';
try
RisultatoPost := lHTTP.Post(Comando, lParamList);
except
on E: EIdHTTPProtocolException do
begin
Memo1.Lines.Add(E.ErrorMessage);
end;
end;
finally
lHTTP.Free;
end;
finally
lParamList.Free;
end;
end;
I have this error:
{"timestamp":"2019-03-01T21:45:29.634+0000","status":400,"error":"Bad Request","message":"JSON parse error: Unexpected character ('%' (code 37)): expected a valid value (number, String, array, object, 'true', 'false' or 'null'); nested exception is com.fasterxml.jackson.core.JsonParseException: Unexpected character ('%' (code 37)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: (PushbackInputStream); line: 1, column: 2]","path":"/core-trasmissione-rest-fattura/services/invoice/upload"}
THIS IS THE DOCUMENTATION:
7.1. Upload invoice
Questo metodo deve essere utilizzato dall’OE per effettuare l’invio di una fattura già nel formato XML secondo norme AGID, ma non ancora firmata digitalmente.
HTTP request
I parametri [i]"domain" e "credential" rappresentano rispettivamente il dominio e le credenziali di firma automatica se possedute dall’utente, in caso contrario lasciare tali campi vuoti.[/i]
Request headers
Name
Description
Provisioner access token
Request fields
Path
Type
Description
Dati allegato in formato encoded Base64
Credenziali firma
Domain firma
HTTP response
Response fields
Path
Type
Description
Nome file fattura (inviato a SdI) restituito dal ws
Eventuale codice di errore
Eventuale descrizione errore
thanks
I have this function
function TFDMFE.EncodeFile(const FileName: string): AnsiString;
var
stream: TMemoryStream;
begin
stream := TMemoryStream.Create;
try
stream.LoadFromFile(filename);
result := EncodeBase64(stream.Memory, stream.Size);
finally
FreeAndNil(stream);
end;
end;
procedure TFDMFE.InviaFE(Autorizzazione, PercorsoFileXML, Credenziali, Dominio : string);
var
lHTTP: TIdHTTP;
lParamList: TStringList;
Comando, RisultatoPost : string;
begin
//************ COMANDO HTTP ********
Comando := 'https://ws.fatturazioneelettronica.aruba.it/services/invoice/upload';
//**********************************
lParamList := TStringList.Create;
Credenziali := '""';
Dominio := '""';
try
lParamList.Add('"dataFile":"'+EncodeFile(PercorsoFileXML)+'"');
lParamList.Add('"credential":'+Credenziali); // vuoti
lParamList.Add('"domain":'+Dominio); // vuoti
lHTTP := TIdHTTP.Create;
try
lHTTP.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(lHTTP);
lHTTP.HandleRedirects := True;
lHTTP.Request.CustomHeaders.FoldLines := False;
lHTTP.Request.Accept := 'application/json';
lHTTP.Request.CustomHeaders.Add('Authorization:Bearer ' + Autorizzazione);
lHTTP.Request.ContentType := 'application/json';
lHTTP.Request.CharSet := 'UTF-8';
try
RisultatoPost := lHTTP.Post(Comando, lParamList);
except
on E: EIdHTTPProtocolException do
begin
Memo1.Lines.Add(E.ErrorMessage);
end;
end;
finally
lHTTP.Free;
end;
finally
lParamList.Free;
end;
end;
I have this error:
{"timestamp":"2019-03-01T21:45:29.634+0000","status":400,"error":"Bad Request","message":"JSON parse error: Unexpected character ('%' (code 37)): expected a valid value (number, String, array, object, 'true', 'false' or 'null'); nested exception is com.fasterxml.jackson.core.JsonParseException: Unexpected character ('%' (code 37)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: (PushbackInputStream); line: 1, column: 2]","path":"/core-trasmissione-rest-fattura/services/invoice/upload"}
THIS IS THE DOCUMENTATION:
7.1. Upload invoice
Code:
POST /services/invoice/uploadQuesto metodo deve essere utilizzato dall’OE per effettuare l’invio di una fattura già nel formato XML secondo norme AGID, ma non ancora firmata digitalmente.
HTTP request
Code:
POST /services/invoice/upload HTTP/1.1
Accept: application/json
Authorization: Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE=
Content-Type: application/json;charset=UTF-8
{
"dataFile" : "dGVzdA==",
"credential" : "",
"domain" : ""
}I parametri [i]"domain" e "credential" rappresentano rispettivamente il dominio e le credenziali di firma automatica se possedute dall’utente, in caso contrario lasciare tali campi vuoti.[/i]
Request headers
Name
Description
Code:
AuthorizationProvisioner access token
Request fields
Path
Type
Description
Code:
dataFileCode:
StringDati allegato in formato encoded Base64
Code:
credentialCode:
StringCredenziali firma
Code:
domainCode:
StringDomain firma
HTTP response
Code:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 105
{
"errorCode" : "",
"errorDescription" : "",
"uploadFileName" : "IT01490810845_uxjhl.xml.p7m"
}Response fields
Path
Type
Description
Code:
uploadFileNameCode:
StringNome file fattura (inviato a SdI) restituito dal ws
Code:
errorCodeCode:
StringEventuale codice di errore
Code:
errorDescriptionCode:
StringEventuale descrizione errore
thanks

