Quantcast
Channel: Embarcadero Community - Embarcadero Community
Viewing all articles
Browse latest Browse all 3212

REST Request - Error to get PDF Attached - Berlin 10.1

$
0
0

Hi!

Iam trying to download a PDF file using a REST Client.

When it's execute, the request reach the server and get the content. But when try to convert the content to a string this throw the exception "class EEncodingError with message 'No mapping for the Unicode character exists in the target multi-byte code page'."

I've debuged the code, and the error occurs when try to get the count of chars in GetString function of System.SysUtils unit.

//Line 31441

Len := GetCharCount(Bytes, ByteIndex, ByteCount);  //ByteCount = 364510

This function call the MultiByteToWideChar function and this return 0. //CodePage = 65001

When I change the value of "Len" using the debugger, the stream can be readed.

This is the example of configuration used at the components:

object RESTClient1: TRESTClient
  Accept = 'application/json, text/plain; q=0.9, text/html;q=0.8, application/octet-stream,'
  AcceptCharset = 'UTF-8, *;q=0.5'
  AcceptEncoding = 'deflate, gzip, *;q=0'
  BaseURL = '...'
  Params = <>
  HandleRedirects = True
end
 
object RESTRequest1: TRESTRequest
  Accept = 'application/json, text/plain; q=0.9, text/html;q=0.8, application/octet-stream,'
  AcceptCharset = 'UTF-8, *;q=0.5'
  AcceptEncoding = 'deflate, gzip, *;q=0'
  Client = RESTClient1
  Params = <
    item
      Kind = pkHTTPHEADER
      name = 'Param1'
      Value = '...'
    end
    item
      Kind = pkHTTPHEADER
      name = 'Authorization'
      Options = [poDoNotEncode]
      Value = '...'
    end>
  Resource = 'Documents/CODE/RepGrph/Binary'
  Response = RESTResponse1
  SynchronizedEvents = False
end
 
object RESTResponse1: TRESTResponse
end

Thanks for your help.


Viewing all articles
Browse latest Browse all 3212

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>