Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem with post methos https - URGENT
#1
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
Code:
POST /services/invoice/upload

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
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:
Authorization

Provisioner access token

Request fields
Path
Type
Description

Code:
dataFile

Code:
String

Dati allegato in formato encoded Base64

Code:
credential

Code:
String

Credenziali firma

Code:
domain

Code:
String

Domain 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:
uploadFileName

Code:
String

Nome file fattura (inviato a SdI) restituito dal ws

Code:
errorCode

Code:
String

Eventuale codice di errore

Code:
errorDescription

Code:
String

Eventuale descrizione errore



thanks
Reply


Messages In This Thread
problem with post methos https - URGENT - by staff@ergosoft.it - 03-01-2019, 09:48 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)