私のアプリケーションは "application/json"を使用してデータ(個人情報)を送信します。データが有効であれば、サーバーは "application/pdf"を通して私にPDFファイルを送り返します。しかし、RestResponseが到着すると、「ターゲットのマルチバイトコードページにUnicode文字のマッピングが存在しません」という例外が表示されます。私は何が起こっているのか分からない。私は過去4日間でこれについて取り組んでおり、私はこれを解決できません。例外は、行: "RRequest.Execute;"でポップアウトします。ここに私のコードの男です:RestResponseを使用してcontentType "application/pdf"を受信できません
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 := TRESTRequest.Create(RRequest);
with RRequest do begin
Accept := 'application/json;text/plain;application/pdf;';
Client := RClient;
Method := rmPost;
SynchronizedEvents := false;
AcceptCharset := 'UTF-8';
end;
RResponse := TRESTResponse.Create(RResponse);
RResponse.ContentType := 'application/pdf;*/*;';
RResponse.ContentEncoding := 'UTF-8';
RAuth := THTTPBasicAuthenticator.Create('','');
with RAuth do begin
Username := 'anAPItokenAccess';
Password := 'token';
end;
RClient.Authenticator := RAuth;
RRequest.Response := RResponse;
RRequest.Execute;
PDF.WriteAllBytes(ExtractFilePath(Application.ExeName)+'boleto.pdf',RResponse.RawBytes);
OutputStrings.Add(RResponse.Content);
OutputStrings.Add('');
OutputStrings.Add('');
OutputStrings.AddStrings(RResponse.Headers);
except on E:Exception do
ShowMessage('Error: '+E.Message);
end;
finally
THRBoleto.Free;
end;
end;
私がテストしていますが...しかし、それは私にエラーを与える:「SSLライブラリをロードできませんでした」。 DLLファイルはSystemおよびSysWow64に存在し、EXEのフォルダにも存在します。 – RafaelHarth
最新のDLLはありますか? OpenSSLのどのバージョン?障害が発生した後、Indyの 'IdSSLOpenSSLHeaders.WhichFailedToLoad()'関数は何を言っていますか? –
DLLファイルが動作しています。私はちょうど更新よりも。 – RafaelHarth