TrevorS 3 Posted March 30, 2022 (edited) I have created an API in Node.JS serving data and PDFs to my Angular front end - all works perfectly. I've also added the PDF bit onto an existing Delphi App that my company uses. There are 5 difference classes of PDF document. The Delphi app works 100% of the time, for all PDF types when I compile it for Mac OSX, however, when I run the Windows version, I get problems with 2 document types - 3 work perfectly (I can also use Postman to get the PDFs without any errors on all types) I create the PDFs on the fly in the server, and the problem PDFs are created from the same bits of server code as the ones that fail. Error: No mapping for the Unicode character exists in the target multi-byte code page I've tried changing the headers sent from the server, and also varied the request headers: I've tried different Content-Types and specified the charset=utf-8. The simple Delphi code bellow, works for all PDF types on the Mac, but only works for a subset of the document types on Windows. (It's the RESTRequest.Execute bit that fails) RESTClient.BaseURL := 'https://api.mysite.com/pdf/' + url; RESTREquest.Method := rmGet; RESTRequest.Params.AddItem; RESTRequest.Params[0].Kind := pkHTTPHEADER; RESTRequest.Params[0].ContentType := ctTEXT_PLAIN; RESTRequest.Params[0].Options := [ poDoNotEncode ]; RESTRequest.Params[0].name := 'authorization'; RESTRequest.Params[0].value := 'Bearer ' + Token; RESTRequest.Execute; if RESTResponse.StatusCode = 200 then begin RespBytes := RESTResponse.RawBytes; Edited March 30, 2022 by TrevorS Clarify where the error occurs Share this post Link to post
TrevorS 3 Posted March 30, 2022 Embarcadero® RAD Studio 10.4 Version 27.0.38860.1461 Delphi 10.4 and C++ Builder 10.4 Update 1 Share this post Link to post
TrevorS 3 Posted July 8, 2022 This fixes the problem RESTRequest.Client.FallbackCharsetEncoding := 'raw'; Share this post Link to post