UTF-8 vs ISO-8859-1 gives "Exceeding stated content length of 35"

  • 1
  • Problem
  • Updated 2 months ago
Hi,

Using the Java SDK, when trying to upload a folder having a name containing the Norwegian letter Ø I get the error message "java.net.ProtocolException: Exceeding stated content length of 35". 

I guess this happens because contentLength is set in SFApiQueryExecutor.handleHttPost with body.getBytes(), no charset specified. With our default charset ISO-8859-1 the contentLength is set to 34. However, in SFHttpsCaller.postBody the charset specified is UTF_8, which apparently uses two bytes to represent the letter Ø. Hence we get the error message stated above.

Could perhaps SFApiQueryExecutor.handleHttPost specify which charset to use in order to figure out the contentLength?

 conn.setRequestProperty(SFKeywords.CONTENT_LENGTH,""+body.getBytes(SFKeywords.UTF_8).length);  // Bold is added

Sincerely,
Øystein Molnes

Photo of Øystein Molnes

Øystein Molnes

  • 8 Posts
  • 0 Reply Likes

Posted 2 months ago

  • 1

Be the first to post a reply!