Hola a todos.
Estoy tratando de descargar un PDF usando REST (TRESTClient, TRESTRequest y TRESTResponse).
Al ejecutar la solicitud, va hasta el recurso en la plataforma donde está la API y lo descarga, pero no lo muestra ya que genera el error:
Cita:
Project raised exception class EEncodingError with message 'No mapping for the Unicode character exists in the target multi-byte code page'.
|
Código Delphi
[-]
function THTTPResponse.ContentAsString(const AnEncoding: TEncoding): string;
begin
try
LReader.CopyFrom(LStream, 0); Result := LReader.DataString; finally
if LFreeLStream then
LStream.Free;
end;
end;
function TEncoding.GetString(const Bytes: TBytes; ByteIndex, ByteCount: Integer): string;
var
Len: Integer;
begin
Len := GetCharCount(Bytes, ByteIndex, ByteCount); if (ByteCount > 0) and (Len = 0) then
raise EEncodingError.CreateRes(@SNoMappingForUnicodeCharacter); SetLength(Result, Len);
GetChars(@Bytes[ByteIndex], ByteCount, PChar(Result), Len);
end;
Estos son los componentes con los parámetros básicos de la solicitud
Código Delphi
[-]
object RESTClient1: TRESTClient
Accept = '*/*'
AcceptCharset = 'UTF-8, *;q=0.8'
AcceptEncoding = 'deflate, gzip'
BaseURL = 'https://...'
ContentType = 'application/octet-stream'
Params = <>
HandleRedirects = True
RaiseExceptionOn500 = False
end
object RESTRequest1: TRESTRequest
Accept = '*/*'
AcceptEncoding = 'deflate, gzip'
Client = RESTClient1
Params = <
item
Kind = pkHTTPHEADER
name = 'X-Who'
Value = '...'
end
item
Kind = pkHTTPHEADER
name = 'Authorization'
Options = [poDoNotEncode]
Value = '...'
end>
Resource = 'Documents/LDF/RepresentacionGrafica/Binario'
Response = RESTResponse1
SynchronizedEvents = False
end
object RESTResponse1: TRESTResponse
ContentType = 'application/octet-stream'
ContentEncoding = 'deflate, gzip'
end
como muestro en la info que adjunto, he estado revisando algunas cosas pero debe ser que ya es viernes a las 17:05 o que la gripe me esta afectando. Pero no doy con la forma de obtener este PDF. (Desde un cliente REST de escritorio si funciona)
De ante mano muchas gracias por cualquier guía que me puedan dar.