我的应用程序使用"application/json"发送数据(个人信息).如果数据有效,则服务器通过"application/pdf"向我发回PDF文件.但是当RestResponse到达时,会弹出一个异常:"目标多字节代码页中不存在unicode字符的映射".我不知道发生了什么事.我在过去的4天里正在研究这个问题,我无法解决这个问题.异常弹出:"RRequest.Execute;".这是我的代码人:
procedure TThreadBoleto.Execute;
var
RCtx : TRttiContext;
RType : TRttiType;
RProp : TRttiProperty;
I : integer;
PDF : TFile;
begin
try
try
RClient := TRESTClient.Create('');
with RClient do begin
AcceptEncoding := 'identity';
FallbackCharsetEncoding := 'UTF-8';
Accept := 'application/json;text/plain;application/pdf;';
AcceptCharset := 'UTF-8';
BaseURL := 'https://sandbox.boletocloud.com/api/v1/boletos';
ContentType := 'application/x-www-form-urlencoded';
HandleRedirects := true;
RCtx := TRttiContext.Create;
RType := RCtx.GetType(THRBoleto.ClassType);
I := 0;
for RProp in RType.GetProperties do
begin
Params.AddItem;
Params.Items[I].name := LowerCase(RProp.Name.Replace('_','.'));
Params.Items[I].Value := RProp.GetValue(THRBoleto).AsString;
I := I + 1;
end;
end;
RRequest …Run Code Online (Sandbox Code Playgroud)